use tideway::{Config, ConfigBuilder};

/// App configuration loaded from environment variables.
pub struct AppConfig {
    pub tideway: Config,
    pub database_url: Option<String>,
    pub jwt_secret: Option<String>,
}

impl AppConfig {
    pub fn from_env() -> Self {
        let tideway = ConfigBuilder::new()
            .from_env()
            .build()
            .expect("Invalid TIDEWAY_* config");

        Self {
            tideway,
            database_url: std::env::var("DATABASE_URL").ok(),
            jwt_secret: std::env::var("JWT_SECRET").ok(),
        }
    }
}
