pub mod api; pub mod cron; pub mod database; pub mod directory_browser; pub mod error; pub mod process_job; pub mod python_env; pub mod python_mirrors; pub mod runs; pub mod scheduler; pub mod security; pub mod state; pub mod tasks; use axum::Router; use sqlx::SqlitePool; use tower_http::{ services::{ServeDir, ServeFile}, trace::TraceLayer, }; pub async fn app( pool: SqlitePool, logs_dir: std::path::PathBuf, ) -> crate::error::ApiResult { let state = state::AppState::start(pool, logs_dir).await?; Ok(router(state)) } pub fn router(state: state::AppState) -> Router { api::router(state).layer(TraceLayer::new_for_http()) } pub fn router_with_static(state: state::AppState, static_dir: std::path::PathBuf) -> Router { let index = static_dir.join("index.html"); let router = if index.is_file() { api::router(state) .fallback_service(ServeDir::new(&static_dir).fallback(ServeFile::new(index))) } else { api::router(state) }; router.layer(TraceLayer::new_for_http()) }