use std::env; #[derive(Debug, Clone)] pub struct Config { pub database_url: String, pub tap_ws_url: String, pub host: String, pub port: u16, } impl Config { pub fn from_env() -> Self { let port = match env::var("PORT") { Ok(p) => match p.parse::() { Ok(port) => port, Err(_) => { tracing::warn!(value = %p, "Invalid PORT value, using default 3000"); 3000 } }, Err(_) => 3000, }; Self { database_url: env::var("DATABASE_URL") .unwrap_or_else(|_| "postgres://postgres:postgres@localhost:5432/prism".to_string()), tap_ws_url: env::var("TAP_WS_URL") .unwrap_or_else(|_| "ws://localhost:2480/channel".to_string()), host: env::var("HOST").unwrap_or_else(|_| "0.0.0.0".to_string()), port, } } }