3 Commits

Author SHA1 Message Date
e7e6fd904b Add icarus_base_api_url_env (#8)
All checks were successful
Release Tagging / release (push) Successful in 31s
Reviewed-on: #8
Co-authored-by: kdeng00 <kundeng00@pm.me>
Co-committed-by: kdeng00 <kundeng00@pm.me>
2025-06-12 19:14:27 +00:00
dbe4dc67cb DBURL name change (#7)
All checks were successful
Release Tagging / release (push) Successful in 31s
Reviewed-on: #7
Co-authored-by: kdeng00 <kundeng00@pm.me>
Co-committed-by: kdeng00 <kundeng00@pm.me>
2025-06-01 01:26:37 +00:00
6c37c19a57 filled out (#6)
All checks were successful
Release Tagging / release (push) Successful in 27s
Reviewed-on: #6
Co-authored-by: kdeng00 <kundeng00@pm.me>
Co-committed-by: kdeng00 <kundeng00@pm.me>
2025-06-01 01:18:56 +00:00
6 changed files with 20 additions and 6 deletions

View File

@@ -6,3 +6,4 @@ POSTGRES_MAIN_PASSWORD=password
POSTGRES_MAIN_DB=my_db
POSTGRES_MAIN_HOST=localhost
DATABASE_URL=postgres://${POSTGRES_MAIN_USER}:${POSTGRES_MAIN_PASSWORD}@${POSTGRES_MAIN_HOST}:5432/${POSTGRES_MAIN_DB}
ICARUS_BASE_API_URL=https://icarus.com

2
Cargo.lock generated
View File

@@ -277,7 +277,7 @@ checksum = "f154ce46856750ed433c8649605bf7ed2de3bc35fd9d2a9f30cddd873c80cb08"
[[package]]
name = "icarus_envy"
version = "0.1.0"
version = "0.2.0"
dependencies = [
"async-std",
"dotenvy",

View File

@@ -1,6 +1,6 @@
[package]
name = "icarus_envy"
version = "0.1.0"
version = "0.2.0"
edition = "2024"
rust-version = "1.86"

5
README.md Normal file
View File

@@ -0,0 +1,5 @@
This is a library used to retrieve environment variables associated with various
icarus projects. Rather than having the various icarus projects such as icarus,
icarus_auth, songparser, and others, have environment code, it would be more
efficient to consolidate it. Especially, if there are commonly used environment
variables used throughout the apps.

View File

@@ -1,7 +1,7 @@
pub async fn get_db_url() -> String {
dotenvy::dotenv().ok();
std::env::var(crate::keys::DBURL).expect(crate::keys::error::ERROR)
std::env::var(crate::keys::DB_URL).expect(crate::keys::error::DB_URL)
}
pub async fn get_secret_main_key() -> String {
@@ -18,3 +18,8 @@ pub async fn get_root_directory() -> String {
dotenvy::dotenv().ok();
std::env::var(crate::keys::ROOT_DIRECTORY).expect(crate::keys::error::ROOT_DIRECTORY)
}
pub async fn get_icarus_base_api_url() -> String {
dotenvy::dotenv().ok();
std::env::var(crate::keys::ICARUS_BASE_API_URL).expect(crate::keys::error::ICARUS_BASE_API_URL)
}

View File

@@ -1,6 +1,5 @@
// TODO: Change this to snake case
// Environment key for Database management
pub const DBURL: &str = "DATABASE_URL";
pub const DB_URL: &str = "DATABASE_URL";
// Environment key for secret main key
// Used for the icarus app
@@ -13,9 +12,13 @@ pub const SECRET_KEY: &str = "SECRET_KEY";
// Environment key for root directory for the icarus app
pub const ROOT_DIRECTORY: &str = "ROOT_DIRECTORY";
// Environment key for icarus api url
pub const ICARUS_BASE_API_URL: &str = "ICARUS_BASE_API_URL";
pub mod error {
pub const ERROR: &str = "DATABASE_URL must be set in .env";
pub const DB_URL: &str = "DATABASE_URL must be set in .env";
pub const SECRET_KEY: &str = "SECRET_KEY must be set in environment file";
pub const SECRET_MAIN_KEY: &str = "SECRET_MAIN_KEY must not be set in environment file";
pub const ROOT_DIRECTORY: &str = "ROOT_DIRECTORY must not be set in environment file";
pub const ICARUS_BASE_API_URL: &str = "ICARUS_BASE_API_URL must not be set in enviornment file";
}