Added gitignore

This commit is contained in:
2022-10-20 21:46:33 +02:00
commit 8ca54cde57
35 changed files with 4774 additions and 0 deletions

View 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"}

View File

@@ -0,0 +1,3 @@
pub struct ExternalApi;
impl ExternalApi {}

View File

@@ -0,0 +1,8 @@
pub mod external_api;
pub struct Api;
impl Api {
pub async fn serve(config: vidow_core::config::AppConfig) {}
}

View File

@@ -0,0 +1 @@
/target

View 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"

View 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(())
}

View 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"

View 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
}
}

View File

@@ -0,0 +1,2 @@
pub mod config;
pub use config::AppConfig;

View File

@@ -0,0 +1 @@
pub mod config;