Added gitignore
This commit is contained in:
9
vidow-backend/crates/vidow_api/Cargo.toml
Normal file
9
vidow-backend/crates/vidow_api/Cargo.toml
Normal file
@@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "vidow_api"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
vidow_core = {path = "../vidow_core"}
|
3
vidow-backend/crates/vidow_api/src/external_api.rs
Normal file
3
vidow-backend/crates/vidow_api/src/external_api.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
pub struct ExternalApi;
|
||||
|
||||
impl ExternalApi {}
|
8
vidow-backend/crates/vidow_api/src/lib.rs
Normal file
8
vidow-backend/crates/vidow_api/src/lib.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
pub mod external_api;
|
||||
|
||||
pub struct Api;
|
||||
|
||||
impl Api {
|
||||
pub async fn serve(config: vidow_core::config::AppConfig) {}
|
||||
}
|
||||
|
1
vidow-backend/crates/vidow_bin/.gitignore
vendored
Normal file
1
vidow-backend/crates/vidow_bin/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/target
|
14
vidow-backend/crates/vidow_bin/Cargo.toml
Normal file
14
vidow-backend/crates/vidow_bin/Cargo.toml
Normal file
@@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "vidow_bin"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
vidow_core = { path = "../vidow_core" }
|
||||
|
||||
dotenv = { version = "0.15.0", features = ["clap"] }
|
||||
tracing = { version = "0.1.37", features = ["log"] }
|
||||
tracing-subscriber = { version = "0.3.16", features = ["parking_lot", "serde", "serde_json", "tracing", "tracing-serde", "json", "env-filter"] }
|
||||
eyre = "0.6.8"
|
23
vidow-backend/crates/vidow_bin/src/main.rs
Normal file
23
vidow-backend/crates/vidow_bin/src/main.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
use eyre::Context;
|
||||
use tracing::info;
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
use vidow_core::config::AppConfig;
|
||||
|
||||
#[tokio::main]
|
||||
fn main() -> eyre::Result<()> {
|
||||
dotenv::dotenv().context("could not load .env file")?;
|
||||
let config = AppConfig::new();
|
||||
|
||||
tracing_subscriber::registry()
|
||||
.with(tracing_subscriber::EnvFilter::new(config.rust_log()))
|
||||
.with(tracing_subscriber::fmt::layer())
|
||||
.init();
|
||||
|
||||
info!("environment loaded and configuration parsed");
|
||||
|
||||
Api::serve(config)
|
||||
.await
|
||||
.context("could not initialize api")?;
|
||||
|
||||
Ok(())
|
||||
}
|
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