// #![allow(unused_imports, dead_code, unused_variables, unused_mut)] use actix_files::Files; use actix_web::middleware; use actix_web::web::Data; use actix_web::{web::scope, App, HttpServer}; use log::info; mod db; mod jwt; mod routes; mod state; use routes::{get_posts, login, new_post, register}; use state::CaptchaState; use state::ServerState; #[actix_web::main] async fn main() -> std::io::Result<()> { env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("debug")).init(); let data = ServerState::new().await; let capt_db = CaptchaState::new(); info!("Spinning up server on http://localhost:8080"); HttpServer::new(move || { App::new() .wrap(middleware::Compress::default()) .wrap(middleware::Logger::default()) .wrap(middleware::NormalizePath::trim()) .service( scope("/api") .service(get_posts) .service(new_post) .service(login) .service(register) .app_data(Data::new(data.clone())) .app_data(Data::new(capt_db.clone())), ) .service(Files::new("/", "./public").index_file("index.html")) }) .bind("0.0.0.0:8080")? .run() .await }