This commit is contained in:
Jonas Rabenstein 2026-08-12 13:24:01 +02:00
commit a9d22e8312
18 changed files with 2308 additions and 0 deletions

41
src/config.rs Normal file
View file

@ -0,0 +1,41 @@
use anyhow::Result;
#[derive(Clone)]
pub struct Config {
pub database_url: String,
pub bind_address: String,
pub intervals_base_url: String,
pub intervals_client_id: String,
pub intervals_client_secret: String,
pub intervals_redirect_uri: String,
pub intervals_webhook_secret: String,
pub cookie_secure: bool,
}
impl Config {
pub fn from_env() -> Result<Self> {
dotenvy::dotenv().ok();
Ok(Self {
database_url: std::env::var("DATABASE_URL")?,
bind_address: std::env::var("BIND_ADDRESS")
.unwrap_or_else(|_| "127.0.0.1:8080".into()),
intervals_base_url: std::env::var("INTERVALS_BASE_URL")
.unwrap_or_else(|_| "https://intervals.icu".into()),
intervals_client_id: std::env::var("INTERVALS_CLIENT_ID")?,
intervals_client_secret: std::env::var("INTERVALS_CLIENT_SECRET")?,
intervals_redirect_uri: std::env::var("INTERVALS_REDIRECT_URI")?,
intervals_webhook_secret: std::env::var("INTERVALS_WEBHOOK_SECRET")?,
cookie_secure: std::env::var("COOKIE_SECURE")
.unwrap_or_else(|_| "true".into())
.parse()
.unwrap_or(true),
})
}
}