use sqlx::SqlitePool; #[derive(Clone)] pub struct AppState { pub db: SqlitePool, pub jwt_secret: String, } impl AppState { pub fn from_env(db: SqlitePool) -> Self { let jwt_secret = std::env::var("JWT_SECRET").unwrap_or_else(|_| "dev-secret-change-me".to_string()); Self { db, jwt_secret } } } pub fn database_url() -> String { std::env::var("DATABASE_URL").unwrap_or_else(|_| "sqlite:ayos.db".to_string()) } pub fn static_dir() -> Option { std::env::var("STATIC_DIR").ok() } pub fn port() -> u16 { std::env::var("PORT") .ok() .and_then(|p| p.parse().ok()) .unwrap_or(3001) }