57 lines
1.4 KiB
Rust
57 lines
1.4 KiB
Rust
#[macro_use]
|
|
extern crate rocket;
|
|
|
|
#[macro_use]
|
|
extern crate rocket_contrib;
|
|
|
|
// Seemingly necessary to get serde::Serialize into scope for Prost
|
|
// code generation.
|
|
#[macro_use]
|
|
extern crate serde_derive;
|
|
|
|
use rocket_contrib::serve::StaticFiles;
|
|
use rocket_contrib::templates::Template;
|
|
|
|
pub mod catchers;
|
|
pub mod db;
|
|
pub mod errors;
|
|
pub mod migrator;
|
|
pub mod models;
|
|
pub mod routes;
|
|
|
|
#[rocket::main]
|
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
migrator::migrate().await?;
|
|
|
|
let root_routes: Vec<rocket::Route> = {
|
|
routes::root::routes()
|
|
.into_iter()
|
|
.chain(routes::auth::routes().into_iter())
|
|
.collect()
|
|
};
|
|
|
|
let api_routes = routes::api::routes();
|
|
let character_routes = routes::characters::routes();
|
|
let catchers = catchers::catchers();
|
|
|
|
rocket::ignite()
|
|
.attach(Template::fairing())
|
|
//.attach(db::TenebrousDbConn::fairing())
|
|
.manage(crate::db::create_pool().await?)
|
|
.mount("/", root_routes)
|
|
.mount("/characters", character_routes)
|
|
.mount("/api", api_routes)
|
|
.mount(
|
|
"/scripts",
|
|
StaticFiles::from(concat!(env!("CARGO_MANIFEST_DIR"), "/static/scripts")),
|
|
)
|
|
.mount(
|
|
"/protos",
|
|
StaticFiles::from(concat!(env!("CARGO_MANIFEST_DIR"), "/proto")),
|
|
)
|
|
.register(catchers)
|
|
.launch()
|
|
.await
|
|
.map_err(|e| e.into())
|
|
}
|