relay filter/appview bootstrap
1use std::env;
2
3#[derive(Debug, Clone)]
4pub struct Config {
5 pub database_url: String,
6 pub tap_ws_url: String,
7 pub host: String,
8 pub port: u16,
9}
10
11impl Config {
12 pub fn from_env() -> Self {
13 let port = match env::var("PORT") {
14 Ok(p) => match p.parse::<u16>() {
15 Ok(port) => port,
16 Err(_) => {
17 tracing::warn!(value = %p, "Invalid PORT value, using default 3000");
18 3000
19 }
20 },
21 Err(_) => 3000,
22 };
23
24 Self {
25 database_url: env::var("DATABASE_URL")
26 .unwrap_or_else(|_| "postgres://postgres:postgres@localhost:5432/prism".to_string()),
27 tap_ws_url: env::var("TAP_WS_URL")
28 .unwrap_or_else(|_| "ws://localhost:2480/channel".to_string()),
29 host: env::var("HOST").unwrap_or_else(|_| "0.0.0.0".to_string()),
30 port,
31 }
32 }
33}