use std::sync::Arc;

use dotenv::dotenv;
use scel_core::App;
use tracing::info;
use tracing_subscriber::{EnvFilter, FmtSubscriber};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    dotenv().ok();

    let subscriber = FmtSubscriber::builder()
        .with_env_filter(
            EnvFilter::default()
                .add_directive("tower_http=debug".parse().unwrap())
                .add_directive("scel_api=info".parse().unwrap())
                .add_directive("scel=info".parse().unwrap()),
        )
        .finish();

    tracing::subscriber::set_global_default(subscriber)?;

    info!("Starting scel");

    let app = Arc::new(App::new());

    scel_api::Server::new(app.clone()).start().await
}
