#![allow(clippy::blocks_in_conditions)] use std::str::FromStr; #[cfg(feature = "rest")] use rot::rest; #[cfg(feature = "rowing-tera")] use rot::tera; use rot::{scheduled, tera::Config}; use sqlx::{pool::PoolOptions, sqlite::SqliteConnectOptions, ConnectOptions}; #[macro_use] extern crate rocket; #[launch] async fn rocket() -> _ { use sqlx::SqlitePool; env_logger::init(); let connection_options = SqliteConnectOptions::from_str("sqlite://db.sqlite") .unwrap() .log_statements(log::LevelFilter::Debug); let db: SqlitePool = PoolOptions::new() .connect_with(connection_options) .await .unwrap(); let rocket = rocket::build().manage(db.clone()); #[cfg(feature = "rowing-tera")] let rocket = tera::config(rocket); #[cfg(feature = "rest")] let rocket = rest::config(rocket); let config: Config = rocket .figment() .extract() .expect("Config extraction failed"); scheduled::schedule(&db, &config); rocket }