diff --git a/packages/backend/native-utils/src/util/config.rs b/packages/backend/native-utils/src/util/config.rs index 84a226c8..ccf14816 100644 --- a/packages/backend/native-utils/src/util/config.rs +++ b/packages/backend/native-utils/src/util/config.rs @@ -3,12 +3,46 @@ use serde_yaml; use std::env; use std::fs; -/// TODO: add more fields #[derive(Debug, PartialEq, Deserialize)] #[serde(rename_all = "camelCase")] #[cfg_attr(feature = "napi", napi_derive::napi(object))] pub struct Config { pub url: String, + pub db: DbConfig, + pub redis: RedisConfig, + pub cache_server: Option, +} + +#[derive(Debug, PartialEq, Deserialize)] +#[cfg_attr(feature = "napi", napi_derive::napi(object))] +pub struct DbConfig { + pub host: String, + pub port: u32, + pub db: String, + pub user: String, + pub pass: String, +} + +#[derive(Debug, PartialEq, Deserialize)] +#[cfg_attr(feature = "napi", napi_derive::napi(object))] +pub struct RedisConfig { + pub host: String, + pub port: u32, + pub user: Option, + pub pass: Option, + pub tls: Option, + #[serde(default)] + pub db: u32, + #[serde(default)] + pub prefix: String, +} + +#[derive(Debug, PartialEq, Deserialize)] +#[serde(rename_all = "camelCase")] +#[cfg_attr(feature = "napi", napi_derive::napi(object))] +pub struct TlsConfig { + pub host: String, + pub reject_unauthorized: bool, } #[cfg_attr(feature = "napi", napi_derive::napi)]