Skip to content

Commit 5faeecd

Browse files
committed
refactor(backend): new crate for storing env variables
1 parent 0cd4eef commit 5faeecd

File tree

11 files changed

+27
-9
lines changed

11 files changed

+27
-9
lines changed

Cargo.lock

+10-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ members = [
3838
"crates/utils/application",
3939
"crates/utils/common",
4040
"crates/utils/database",
41+
"crates/utils/env",
4142
]
4243
resolver = "2"
4344

apps/backend/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ config = { path = "../../crates/config" }
2323
database-models = { path = "../../crates/models/database" }
2424
dependent-models = { path = "../../crates/models/dependent" }
2525
dotenvy = "=0.15.7"
26+
env-utils = { path = "../../crates/utils/env" }
2627
exporter-resolver = { path = "../../crates/resolvers/exporter" }
2728
exporter-service = { path = "../../crates/services/exporter" }
2829
file-storage-resolver = { path = "../../crates/resolvers/file-storage" }

apps/backend/src/main.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ use apalis::{
1919
use aws_sdk_s3::config::Region;
2020
use background::ApplicationJob;
2121
use chrono::{DateTime, TimeZone, Utc};
22-
use common_utils::{
23-
convert_naive_to_utc, ryot_log, COMPILATION_TIMESTAMP, PROJECT_NAME, TEMP_DIR, VERSION,
24-
};
22+
use common_utils::{convert_naive_to_utc, ryot_log, COMPILATION_TIMESTAMP, PROJECT_NAME, TEMP_DIR};
2523
use database_models::prelude::Exercise;
24+
use env_utils::VERSION;
2625
use logs_wheel::LogFileInitializer;
2726
use migrations::Migrator;
2827
use sea_orm::{ConnectionTrait, Database, DatabaseConnection, EntityTrait, PaginatorTrait};

crates/services/miscellaneous/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ database-models = { path = "../../models/database" }
1818
database-utils = { path = "../../utils/database" }
1919
dependent-models = { path = "../../models/dependent" }
2020
enums = { path = "../../enums" }
21+
env-utils = { path = "../../utils/env" }
2122
file-storage-service = { path = "../../services/file-storage" }
2223
futures = { workspace = true }
2324
integration-service = { path = "../../services/integration" }

crates/services/miscellaneous/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use common_models::{
1818
};
1919
use common_utils::{
2020
get_first_and_last_day_of_month, ryot_log, IsFeatureEnabled, SHOW_SPECIAL_SEASON_NAMES,
21-
TEMP_DIR, VERSION,
21+
TEMP_DIR,
2222
};
2323
use database_models::{
2424
access_link, calendar_event, collection, collection_to_entity,
@@ -48,6 +48,7 @@ use enums::{
4848
EntityLot, IntegrationLot, IntegrationProvider, MediaLot, MediaSource,
4949
MetadataToMetadataRelation, SeenState, UserToMediaReason, Visibility,
5050
};
51+
use env_utils::VERSION;
5152
use file_storage_service::FileStorageService;
5253
use futures::TryStreamExt;
5354
use integration_service::{integration_type::IntegrationType, IntegrationService};

crates/utils/common/Cargo.toml

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,5 @@ chrono = { workspace = true }
88
compile-time = "=0.2.0"
99
const-str = { workspace = true }
1010
dotenvy_macro = { workspace = true }
11+
env-utils = { path = "../env" }
1112
reqwest = { workspace = true }
12-
13-
[build-dependencies]
14-
dotenv-build = "0.1.1"

crates/utils/common/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, Utc};
2+
use env_utils::VERSION;
23
use reqwest::header::HeaderValue;
34

45
pub const PROJECT_NAME: &str = "ryot";
56
pub const AUTHOR: &str = "ignisda";
67
pub const AUTHOR_EMAIL: &str = "ignisda2001@gmail.com";
7-
pub const VERSION: &str = env!("APP_VERSION");
88
pub const USER_AGENT_STR: &str = const_str::concat!(
99
AUTHOR,
1010
"/",

crates/utils/env/Cargo.toml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "env-utils"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[build-dependencies]
7+
dotenv-build = "0.1.1"
File renamed without changes.

crates/utils/env/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub const VERSION: &str = env!("APP_VERSION");

0 commit comments

Comments
 (0)