use core::Core; use std::path::PathBuf; use asset_db::FsAssets; use axum::{routing::{get, post}, Router, Json}; use database::DbConn; mod asset_db; mod core; mod database; mod filters; mod handlers; use handlers::{ healthcheck, check_password, AuthRequest}; mod types; #[tokio::main] pub async fn main() { /* pretty_env_logger::init(); let unauthenticated_endpoints = route_healthcheck().or(route_authenticate(core.clone())); let authenticated_endpoints = route_image(core.clone()); */ let conn = DbConn::new(Some("/home/savanni/game.db")); let core = Core::new(FsAssets::new(PathBuf::from("/home/savanni/Pictures")), conn); let app = Router::new().route( "/api/v1/health", get({ let core = core.clone(); move || healthcheck(core) }), ).route( "/api/v1/auth", post({ let core = core.clone(); move |req: Json| handlers::check_password(core, req) }), ); let listener = tokio::net::TcpListener::bind("127.0.0.1:8001") .await .unwrap(); axum::serve(listener, app).await.unwrap(); }