ddstats/src/main.rs

31 lines
737 B
Rust
Raw Normal View History

2023-04-13 17:38:47 +02:00
use database::DatabaseHandler;
2022-11-06 18:41:51 +01:00
#[macro_use]
extern crate rocket;
2022-11-05 19:36:31 +01:00
2023-04-15 21:31:39 +02:00
mod api;
2022-11-06 01:11:43 +01:00
mod database;
2022-11-06 19:53:11 +01:00
2023-04-13 17:38:47 +02:00
#[rocket::main]
async fn main() {
2023-04-15 21:31:39 +02:00
let db = match DatabaseHandler::create().await {
2023-04-13 17:38:47 +02:00
Ok(client) => client,
Err(err) => panic!(
"Encountered an error while connecting to the database!\n{}",
err
),
};
match rocket::build()
2023-04-15 21:31:39 +02:00
.manage(db)
.mount("/api/v1/maps", api::maps::get_all_routes())
2023-04-15 22:03:58 +02:00
.mount("/api/v1/races", api::races::get_all_routes())
.mount("/api/v1/teamraces", api::teamraces::get_all_routes())
2023-04-13 17:38:47 +02:00
.launch()
.await
{
Ok(_) => (),
Err(err) => println!("Encountered an error while starting rocket!\n{}", err),
2022-11-06 19:53:11 +01:00
}
}