23 lines
628 B
Rust
23 lines
628 B
Rust
//! Axum CRUD — yksi endpoint-setti per entiteetti, SQLite-tietokanta.
|
|
|
|
use sqlx::sqlite::SqlitePoolOptions;
|
|
use todo_rs::{app, init_db};
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
let pool = SqlitePoolOptions::new()
|
|
.max_connections(5)
|
|
.connect("sqlite:./app.db?mode=rwc")
|
|
.await
|
|
.expect("Tietokantayhteys epäonnistui");
|
|
|
|
init_db(&pool).await;
|
|
|
|
let listener = tokio::net::TcpListener::bind("127.0.0.1:3000")
|
|
.await
|
|
.expect("Portin kuuntelu epäonnistui");
|
|
|
|
println!("Palvelin käynnissä: http://127.0.0.1:3000");
|
|
axum::serve(listener, app(pool)).await.unwrap();
|
|
}
|