2022-02-17 21:59:04 +01:00
|
|
|
use actix_cors::Cors;
|
|
|
|
use actix_web::{middleware::Logger, web::Data, App, HttpServer};
|
2019-12-07 15:16:46 +01:00
|
|
|
|
2019-12-07 18:59:24 +01:00
|
|
|
mod db;
|
2019-12-07 15:16:46 +01:00
|
|
|
mod handlers;
|
|
|
|
mod schemas;
|
|
|
|
|
2022-02-17 21:59:04 +01:00
|
|
|
use self::{db::get_db_pool, handlers::register};
|
|
|
|
|
2020-09-12 17:49:45 +02:00
|
|
|
#[actix_web::main]
|
2019-12-07 18:59:24 +01:00
|
|
|
async fn main() -> std::io::Result<()> {
|
2023-10-29 02:18:40 +02:00
|
|
|
dotenvy::dotenv().ok();
|
2022-02-17 21:59:04 +01:00
|
|
|
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
|
|
|
|
|
2019-12-07 15:16:46 +01:00
|
|
|
let pool = get_db_pool();
|
|
|
|
|
2022-02-17 21:59:04 +01:00
|
|
|
log::info!("starting HTTP server on port 8080");
|
2022-02-17 22:29:55 +01:00
|
|
|
log::info!("GraphiQL playground: http://localhost:8080/graphiql");
|
2022-02-17 21:59:04 +01:00
|
|
|
|
2019-12-07 15:16:46 +01:00
|
|
|
HttpServer::new(move || {
|
|
|
|
App::new()
|
2022-02-17 21:59:04 +01:00
|
|
|
.app_data(Data::new(pool.clone()))
|
2019-12-07 15:16:46 +01:00
|
|
|
.configure(register)
|
2022-02-17 21:59:04 +01:00
|
|
|
.wrap(Cors::permissive())
|
|
|
|
.wrap(Logger::default())
|
2019-12-07 15:16:46 +01:00
|
|
|
})
|
2022-02-17 21:59:04 +01:00
|
|
|
.workers(2)
|
2022-02-17 21:22:36 +01:00
|
|
|
.bind(("127.0.0.1", 8080))?
|
2019-12-25 17:48:33 +01:00
|
|
|
.run()
|
2019-12-07 18:59:24 +01:00
|
|
|
.await
|
|
|
|
}
|