refactor (v2): better arch
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
33
crates/application/src/config.rs
Normal file
33
crates/application/src/config.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
/// Application-level configuration. Auth and infra adapter config lives in their own crates.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AppConfig {
|
||||
pub base_url: String,
|
||||
pub smart: SmartConfig,
|
||||
/// When false the `/auth/register` endpoint returns 403.
|
||||
pub allow_registration: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SmartConfig {
|
||||
pub neighbour_limit: usize,
|
||||
pub min_similarity: f32,
|
||||
}
|
||||
|
||||
impl Default for SmartConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
neighbour_limit: 10,
|
||||
min_similarity: 0.7,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AppConfig {
|
||||
pub fn from_env() -> Self {
|
||||
Self {
|
||||
base_url: std::env::var("BASE_URL").unwrap_or_else(|_| "http://localhost:3000".into()),
|
||||
smart: SmartConfig::default(),
|
||||
allow_registration: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user