Public Access
feat: initial source commit
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
mod config;
|
||||
mod db;
|
||||
mod models;
|
||||
mod routes;
|
||||
|
||||
use axum::{Router, middleware};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use rusqlite::Connection;
|
||||
use config::Config;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AppState {
|
||||
pub db: Arc<Mutex<Connection>>,
|
||||
pub config: Config,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
let config = Config::load();
|
||||
let conn = db::open(&config.database_path).expect("Failed to open database");
|
||||
let state = AppState {
|
||||
db: Arc::new(Mutex::new(conn)),
|
||||
config: config.clone(),
|
||||
};
|
||||
|
||||
let app = routes::router(state);
|
||||
|
||||
let listener = tokio::net::TcpListener::bind(&config.bind).await.unwrap();
|
||||
println!("🚀 Action Gateway running at http://{}", config.bind);
|
||||
axum::serve(listener, app).await.unwrap();
|
||||
}
|
||||
Reference in New Issue
Block a user