Added keys and environment modules
This commit is contained in:
5
src/environment.rs
Normal file
5
src/environment.rs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
pub async fn get_db_url() -> String {
|
||||||
|
dotenvy::dotenv().ok();
|
||||||
|
std::env::var(crate::keys::DBURL).expect(crate::keys::error::ERROR)
|
||||||
|
}
|
5
src/keys.rs
Normal file
5
src/keys.rs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
pub const DBURL: &str = "DATABASE_URL";
|
||||||
|
|
||||||
|
pub mod error {
|
||||||
|
pub const ERROR: &str = "DATABASE_URL must be set in .env";
|
||||||
|
}
|
Reference in New Issue
Block a user