scroll.server/crates/auth-service/src/config.rs
WiseDev ad5a1613e3 move players and accounts into postgres
json stores are gone, they nulled out every data ref on load and wrote the null straight back on save.
shop json and the purchase commands ended up in here too.
2026-08-23 08:40:13 +03:00

43 lines
1.4 KiB
Rust

use storage::DatabaseConfig;
#[derive(Debug, Clone)]
pub struct AuthConfig {
pub listen: String,
pub database: Option<DatabaseConfig>,
pub min_client_build: i32,
pub max_client_build: i32,
pub content_fingerprint: Option<String>,
pub content_url: Option<String>,
}
impl Default for AuthConfig {
fn default() -> Self {
Self {
listen: "127.0.0.1:9401".to_owned(),
database: None,
min_client_build: 0,
max_client_build: i32::MAX,
content_fingerprint: None,
content_url: None,
}
}
}
impl AuthConfig {
pub fn from_env() -> Self {
let defaults = Self::default();
Self {
listen: env_string("SCROLL_AUTH_LISTEN").unwrap_or(defaults.listen),
database: DatabaseConfig::from_env(),
min_client_build: env_i32("SCROLL_MIN_CLIENT_BUILD")
.unwrap_or(defaults.min_client_build),
max_client_build: env_i32("SCROLL_MAX_CLIENT_BUILD")
.unwrap_or(defaults.max_client_build),
content_fingerprint: env_string("SCROLL_CONTENT_FINGERPRINT"),
content_url: env_string("SCROLL_CONTENT_URL"),
}
}
}
pub fn env_string(key: &str) -> Option<String> {
std::env::var(key).ok().filter(|value| !value.is_empty())
}
pub fn env_i32(key: &str) -> Option<i32> {
env_string(key).and_then(|value| value.parse().ok())
}