feat: add MongoDB support with connection pooling and repository pattern
This commit is contained in:
@@ -4,10 +4,14 @@ use std::env;
|
||||
use std::net::SocketAddr;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[cfg(feature = "no-auth")]
|
||||
use tracing::error;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Config {
|
||||
pub bind_address: SocketAddr,
|
||||
// pub database_url: Option<String>,
|
||||
pub mongodb_uri: String,
|
||||
pub database_name: String,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
@@ -24,11 +28,15 @@ impl Config {
|
||||
return Err("In no-auth mode, BIND_ADDRESS must be 127.0.0.1".to_string());
|
||||
}
|
||||
|
||||
// let database_url = env::var("DATABASE_URL").ok();
|
||||
let mongodb_uri =
|
||||
env::var("MONGODB_URI").unwrap_or_else(|_| "mongodb://localhost:27017".to_string());
|
||||
|
||||
let database_name = env::var("DATABASE_NAME").unwrap_or_else(|_| "purenotify".to_string());
|
||||
|
||||
Ok(Self {
|
||||
bind_address,
|
||||
// database_url,
|
||||
mongodb_uri,
|
||||
database_name,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user