// #![allow(dead_code, unused_imports)] use actix_web::web::Data; use actix_web::{web::scope, App, HttpServer}; use log::info; mod jwt; mod routes; mod state; mod types; use routes::{get_posts, login, new_post, register, test}; use state::AppState; #[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 = AppState::new().await; info!("Spinning up server on http://localhost:8080"); HttpServer::new(move || { App::new().service( scope("api") .service(get_posts) .service(new_post) .service(routes::vote) .service(test) .service(login) .service(register) .app_data(Data::new(data.clone())), ) }) .bind("localhost:8080")? .run() .await }