FrostByte/server/src/main.rs

33 lines
764 B
Rust
Raw Normal View History

2023-10-09 19:21:55 +02:00
use actix_web::web::Data;
use actix_web::{web::scope, App, HttpServer};
// use uuid::Uuid;
mod routes;
mod types;
use log::info;
use routes::{get_posts, new_post, test};
use types::AppState;
#[actix_web::main]
async fn main() -> std::io::Result<()> {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("debug")).init();
info!("Starting server...");
let data = AppState::new();
HttpServer::new(move || {
App::new().service(
scope("api")
.service(get_posts)
.service(new_post)
.service(routes::vote)
.service(test)
.app_data(Data::new(data.clone())),
)
})
.bind("localhost:8080")?
.run()
.await
}