2019-12-07 15:16:46 +01:00
|
|
|
#[macro_use]
|
|
|
|
extern crate juniper;
|
|
|
|
extern crate r2d2;
|
|
|
|
extern crate r2d2_mysql;
|
|
|
|
extern crate serde_json;
|
|
|
|
|
2019-12-07 18:59:24 +01:00
|
|
|
use actix_web::{middleware, web, App, HttpServer};
|
2019-12-07 15:16:46 +01:00
|
|
|
|
|
|
|
use crate::db::get_db_pool;
|
2019-12-07 18:59:24 +01:00
|
|
|
use crate::handlers::register;
|
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;
|
|
|
|
|
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<()> {
|
2019-12-07 15:16:46 +01:00
|
|
|
dotenv::dotenv().ok();
|
|
|
|
std::env::set_var("RUST_LOG", "actix_web=info,info");
|
|
|
|
env_logger::init();
|
|
|
|
let pool = get_db_pool();
|
|
|
|
|
|
|
|
HttpServer::new(move || {
|
|
|
|
App::new()
|
|
|
|
.data(pool.clone())
|
|
|
|
.wrap(middleware::Logger::default())
|
|
|
|
.configure(register)
|
2019-12-07 18:59:24 +01:00
|
|
|
.default_service(web::to(|| async { "404" }))
|
2019-12-07 15:16:46 +01:00
|
|
|
})
|
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
|
|
|
|
}
|