feat: Added initial scaffold, db schema and entrypoint

This commit is contained in:
2026-06-25 10:15:12 +05:30
parent b9a7bb8319
commit a55fd2e1bd
6 changed files with 3300 additions and 3 deletions

View File

@@ -1,3 +1,45 @@
fn main() {
println!("Hello, world!");
use axum::{Router, routing::get};
use sqlx::{sqlite::SqlitePoolOptions, SqlitePool};
use std::net::SocketAddr;
use tracing_subscriber::EnvFilter;
#[tokio::main]
async fn main() {
tracing_subscriber::fmt()
.with_env_filter(
EnvFilter::from_default_env()
.add_directive("bootstrap_auth_server=debug".parse().unwrap()),
)
.init();
dotenvy::dotenv().ok();
let db_url = std::env::var("DATABASE_URL").unwrap_or_else(|_| "sqlite://data.db?mode=rwc".to_string());
tracing::info!("Connecting to database at {}", db_url);
let pool = SqlitePoolOptions::new()
.max_connections(5)
.connect(&db_url)
.await
.expect("Failed to connect to SQLite database");
tracing::info!("Running database migrations...");
sqlx::migrate!("./migrations")
.run(&pool)
.await
.expect("Failed to run database migrations");
tracing::info!("Migrations successful.");
let app = Router::new()
.route("/health", get(|| async { "OK" }))
.with_state(pool);
let port = std::env::var("SERVER_PORT").unwrap_or_else(|_| "3000".to_string());
let addr: SocketAddr = format!("0.0.0.0:{}", port).parse().unwrap();
tracing::info!("Listening on {}", addr);
let listener = tokio::net::TcpListener::bind(addr).await.unwrap();
axum::serve(listener, app).await.unwrap();
}