summaryrefslogtreecommitdiff
path: root/src/main.rs
blob: d454a8c95338b8d18df5cc85a43bfc6aeaa62094 (plain)
use actix_web::{web::Data, App, HttpServer};
use exun::RawUnexpected;

mod api;
mod models;
mod services;

use services::*;

#[actix_web::main]
async fn main() -> Result<(), RawUnexpected> {
	let db_url = secrets::database_url()?;
	let sql_pool = db::initialize(&db_url).await?;

	HttpServer::new(move || {
		App::new()
			.app_data(Data::new(sql_pool.clone()))
			.service(api::liveops())
			.service(api::users())
			.service(api::ops())
	})
	.shutdown_timeout(1)
	.bind(("127.0.0.1", 8080))?
	.run()
	.await?;

	Ok(())
}