use once_cell::sync::Lazy;
use serde_derive::{Deserialize, Serialize};

#[derive(Serialize, Deserialize)]
pub struct Config {
    pub db_url: String,
    pub server_url: String,
}

pub static CONFIG: Lazy<Config> =
    Lazy::new(|| confy::load("starchart", Some("config")).expect("failed to load config"));

impl Default for Config {
    fn default() -> Self {
        Self {
            db_url: "postgres://starchart:hunter2@localhost/starchart".into(),
            server_url: "127.0.0.1:7056/".into(),
        }
    }
}
