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:
+4
-13
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user