This allows us to pull them into the coverage report. Reviewed-on: #12 Co-authored-by: Drew Galbraith <drew@tiramisu.one> Co-committed-by: Drew Galbraith <drew@tiramisu.one>
33 lines
938 B
Rust
33 lines
938 B
Rust
use axum::{Router, routing::get};
|
|
|
|
mod database;
|
|
mod models;
|
|
mod services;
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
tracing_subscriber::fmt::init();
|
|
|
|
let database_url = std::env::var("DATABASE_URL").unwrap_or("sqlite:local.db".to_string());
|
|
let binding = database::DatabaseConfig { database_url };
|
|
let pool = database::create_pool(&binding)
|
|
.await
|
|
.expect("Failed to create database pool");
|
|
let app = Router::new()
|
|
.route("/health", get(health))
|
|
.nest("/api/tasks", services::create_task_router())
|
|
.with_state(pool);
|
|
|
|
let port = std::env::var("PORT").unwrap_or("3000".to_string());
|
|
let addr = format!("127.0.0.1:{}", port);
|
|
|
|
let listener = tokio::net::TcpListener::bind(addr).await.unwrap();
|
|
|
|
tracing::info!("API Server listening on {}", listener.local_addr().unwrap());
|
|
|
|
axum::serve(listener, app).await.unwrap();
|
|
}
|
|
|
|
async fn health() -> &'static str {
|
|
"Ok"
|
|
}
|