use std::{ sync::Arc, }; mod error; use clap::Parser; use anyhow::Context; use como_api::router::Api; use como_infrastructure::{ configs::AppConfig, database::ConnectionPoolManager, register::ServiceRegister, }; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() -> anyhow::Result<()> { tracing::info!("Loading dotenv"); dotenv::dotenv()?; let config = Arc::new(AppConfig::parse()); tracing_subscriber::registry() .with(tracing_subscriber::EnvFilter::new( std::env::var("RUST_LOG").unwrap_or_else(|_| { "como_bin=debug,tower_http=debug,axum_extra=debug,hyper=info,mio=info,sqlx=info,async_graphql=debug" .into() }), )) .with(tracing_subscriber::fmt::layer()) .init(); let pool = ConnectionPoolManager::new_pool(&config.database_url, true).await?; let service_register = ServiceRegister::new(pool, config.clone()); Api::new(3001, &config.cors_origin, service_register.clone()) .await .context("could not initialize API")?; Ok(()) }