simple-web-app

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

main.rs (762B)


      1 mod auth;
      2 mod config;
      3 mod database;
      4 mod error;
      5 mod handlers;
      6 mod migrations;
      7 mod routes;
      8 mod sse;
      9 mod state;
     10 mod templates;
     11 
     12 use config::Config;
     13 use database::Database;
     14 use state::AppState;
     15 
     16 #[tokio::main]
     17 async fn main() -> Result<(), Box<dyn std::error::Error>> {
     18     let config = Config::from_env();
     19 
     20     eprintln!("Starting server with DEBUG={}", config.debug);
     21     eprintln!("Database path: {}", config.db_path);
     22 
     23     let db = Database::new(&config.db_path)?;
     24     let addr = config.addr.clone();
     25     let state = AppState::new(config, db);
     26 
     27     let app = routes::create_router(state);
     28 
     29     let listener = tokio::net::TcpListener::bind(&addr).await?;
     30     eprintln!("Server listening on http://{}", addr);
     31 
     32     axum::serve(listener, app).await?;
     33 
     34     Ok(())
     35 }