dynamic_db (#17)

Reviewed-on: phoenix/icarus_auth#17
Co-authored-by: phoenix <kundeng94@gmail.com>
Co-committed-by: phoenix <kundeng94@gmail.com>
This commit is contained in:
phoenix
2025-04-05 01:30:35 +00:00
committed by phoenix
parent 6bdc893147
commit d7c3443022
11 changed files with 367 additions and 91 deletions
+4 -13
View File
@@ -1,20 +1,15 @@
pub mod callers;
pub mod config;
pub mod hashing;
pub mod models;
pub mod repo;
mod keys {
pub mod keys {
pub const DBURL: &str = "DATABASE_URL";
pub mod error {
pub const ERROR: &str = "DATABASE_URL must be set in .env";
}
pub mod test {
pub const DBURL: &str = "TEST_DATABASE_URL";
pub mod error {
pub const ERROR: &str = "TEST_DATABASE_URL must be set in .env";
}
}
}
mod connection_settings {
@@ -42,10 +37,6 @@ pub mod db_pool {
#[cfg(debug_assertions)] // Example: Only load .env in debug builds
dotenvy::dotenv().ok();
if cfg!(debug_assertions) {
env::var(keys::test::DBURL).expect(keys::test::error::ERROR)
} else {
env::var(keys::DBURL).expect(keys::error::ERROR)
}
env::var(keys::DBURL).expect(keys::error::ERROR)
}
}