mod api; mod tokens; use anyhow::Result; use clap::Parser; use log::info; use sqlx::mysql::MySqlPool; #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] struct Args { /// Sets the port on which the API listens #[arg(short, long)] port: Option, } #[tokio::main] async fn main() -> Result<()> { env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); info!("Starting NerdcultAPI v0.1"); let args = Args::parse(); let mut port: u16 = 8080; if let Some(p) = args.port { port = p; } let pool = MySqlPool::connect(&std::env::var("DATABASE_URL").map_err(|_| { anyhow::Error::msg("Environment variable DATABASE_URL needs to be specified!") })?) .await?; api::start(port, pool).await?; Ok(()) }