chore: add more fields to Config type (native-utils)

This commit is contained in:
naskya 2024-01-17 06:34:33 +09:00
parent d6dd6ff897
commit fb8a8614f4
Signed by: naskya
GPG key ID: 712D413B3A9FED5C

View file

@ -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<RedisConfig>,
}
#[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<String>,
pub pass: Option<String>,
pub tls: Option<TlsConfig>,
#[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)]