Add pre-commit config

This commit is contained in:
2023-09-24 22:49:42 +02:00
parent 2b26503cf1
commit 6d4765dc75
12 changed files with 189 additions and 271 deletions

View File

@@ -9,15 +9,13 @@ pub struct Config {
pub postgres_port: u32,
pub postgres_db: String,
pub sentry_dsn: String
pub sentry_dsn: String,
}
fn get_env(env: &'static str) -> String {
std::env::var(env).unwrap_or_else(|_| panic!("Cannot get the {} env variable", env))
}
impl Config {
pub fn load() -> Config {
Config {
@@ -29,12 +27,9 @@ impl Config {
postgres_port: get_env("POSTGRES_PORT").parse().unwrap(),
postgres_db: get_env("POSTGRES_DB"),
sentry_dsn: get_env("SENTRY_DSN")
sentry_dsn: get_env("SENTRY_DSN"),
}
}
}
pub static CONFIG: Lazy<Config> = Lazy::new(|| {
Config::load()
});
pub static CONFIG: Lazy<Config> = Lazy::new(Config::load);