Added gitignore
This commit is contained in:
10
vidow-backend/crates/vidow_core/Cargo.toml
Normal file
10
vidow-backend/crates/vidow_core/Cargo.toml
Normal file
@@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "vidow_core"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.0.17", features = ["env", "derive"] }
|
||||
eyre = "0.6.8"
|
55
vidow-backend/crates/vidow_core/src/config/config.rs
Normal file
55
vidow-backend/crates/vidow_core/src/config/config.rs
Normal file
@@ -0,0 +1,55 @@
|
||||
use clap::Parser;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Parser)]
|
||||
pub struct AppConfigInner {
|
||||
#[clap(long, env)]
|
||||
pub database_url: String,
|
||||
|
||||
#[clap(long, env)]
|
||||
pub rust_log: String,
|
||||
|
||||
#[clap(long, env)]
|
||||
pub external_port: u32,
|
||||
|
||||
#[clap(long, env)]
|
||||
pub internal_port: u32,
|
||||
|
||||
#[clap(long, env)]
|
||||
pub run_migrations: bool,
|
||||
|
||||
#[clap(long, env)]
|
||||
pub cors_origin: String,
|
||||
}
|
||||
|
||||
pub struct AppConfig {
|
||||
inner: Arc<AppConfigInner>,
|
||||
}
|
||||
|
||||
impl AppConfig {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
inner: Arc::new(AppConfigInner::parse()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cfg(&self) -> Arc<AppConfigInner> {
|
||||
self.inner.clone()
|
||||
}
|
||||
|
||||
pub fn rust_log(&self) -> &str {
|
||||
&self.inner.rust_log
|
||||
}
|
||||
|
||||
pub fn cors_origin(&self) -> &str {
|
||||
&self.inner.rust_log
|
||||
}
|
||||
|
||||
pub fn external_port(&self) -> &u32 {
|
||||
&self.inner.external_port
|
||||
}
|
||||
|
||||
pub fn internal_port(&self) -> &u32 {
|
||||
&self.inner.internal_port
|
||||
}
|
||||
}
|
2
vidow-backend/crates/vidow_core/src/config/mod.rs
Normal file
2
vidow-backend/crates/vidow_core/src/config/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
pub mod config;
|
||||
pub use config::AppConfig;
|
1
vidow-backend/crates/vidow_core/src/lib.rs
Normal file
1
vidow-backend/crates/vidow_core/src/lib.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod config;
|
Reference in New Issue
Block a user