mi/backend/src/main.rs

43 lines
1.1 KiB
Rust
Raw Normal View History

2020-11-02 18:06:50 +00:00
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate rocket;
#[macro_use]
extern crate tracing;
2020-09-13 16:07:06 +00:00
2020-09-13 15:23:53 +00:00
use color_eyre::eyre::Result;
2020-11-02 18:06:50 +00:00
use rocket_contrib::helmet::SpaceHelmet;
use rocket_prometheus::PrometheusMetrics;
2020-09-13 15:23:53 +00:00
2020-11-03 14:47:19 +00:00
use ::mi::{api, web, MainDatabase, APPLICATION_NAME};
2020-11-02 18:06:50 +00:00
fn main() -> Result<()> {
2020-09-13 15:23:53 +00:00
let _ = kankyo::init();
color_eyre::install()?;
2020-11-02 18:06:50 +00:00
tracing_subscriber::fmt::init();
info!("{} starting up", APPLICATION_NAME);
let prometheus = PrometheusMetrics::with_registry(prometheus::default_registry().clone());
rocket::ignite()
.attach(prometheus.clone())
.attach(MainDatabase::fairing())
.attach(SpaceHelmet::default())
.attach(web::pluralkit::Client::fairing())
2020-11-02 20:54:23 +00:00
.attach(web::switchcounter::Client::fairing())
2020-11-02 18:06:50 +00:00
.mount("/metrics", prometheus)
.mount(
2020-11-02 19:03:32 +00:00
"/",
2020-11-02 18:06:50 +00:00
routes![
api::get_members,
api::get_switches,
2020-11-02 19:16:35 +00:00
api::get_switch,
2020-11-02 18:06:50 +00:00
api::get_current_front,
api::make_switch
],
)
.launch();
2020-09-13 15:23:53 +00:00
Ok(())
}