71 lines
2.5 KiB
Rust
71 lines
2.5 KiB
Rust
use clap::Parser;
|
|
|
|
/// Runtime configuration, sourced from CLI arguments and environment variables.
|
|
#[derive(Debug, Clone, Parser)]
|
|
#[command(version, about = "Collection management system server")]
|
|
pub struct Config {
|
|
/// PostgreSQL connection string.
|
|
#[arg(long, env = "DATABASE_URL")]
|
|
pub database_url: String,
|
|
|
|
/// Address to bind the HTTP server to.
|
|
#[arg(long, env = "BIND_ADDR", default_value = "0.0.0.0:8080")]
|
|
pub bind_addr: String,
|
|
|
|
/// User-facing application name (OpenAPI title, page title, …).
|
|
///
|
|
/// Defaults to a neutral name; set this to the real product name at deploy
|
|
/// time. The product name must never be hardcoded in source.
|
|
#[arg(long, env = "APP_NAME", default_value = "Collection Management System")]
|
|
pub app_name: String,
|
|
|
|
/// Send the session cookie with the `Secure` attribute (HTTPS-only). Disable
|
|
/// only for plain-HTTP self-hosting behind no TLS at all.
|
|
#[arg(
|
|
long = "session-cookie-secure",
|
|
env = "SESSION_COOKIE_SECURE",
|
|
default_value_t = true
|
|
)]
|
|
pub cookie_secure: bool,
|
|
|
|
/// Meilisearch base URL (e.g. `http://localhost:7700`). On-write search indexing
|
|
/// is enabled only when both this and `--meili-master-key` are set; otherwise
|
|
/// search is disabled (best-effort feature) and `reindex_all` remains the rebuild
|
|
/// path.
|
|
#[arg(long = "meili-url", env = "MEILI_URL")]
|
|
pub meili_url: Option<String>,
|
|
|
|
/// Meilisearch API key (master or a scoped key).
|
|
#[arg(long = "meili-master-key", env = "MEILI_MASTER_KEY")]
|
|
pub meili_master_key: Option<String>,
|
|
|
|
/// Meilisearch index name for catalogue objects.
|
|
#[arg(long = "meili-index", env = "MEILI_INDEX", default_value = "objects")]
|
|
pub meili_index: String,
|
|
|
|
/// Maximum size of the PostgreSQL connection pool.
|
|
#[arg(
|
|
long = "db-max-connections",
|
|
env = "DB_MAX_CONNECTIONS",
|
|
default_value_t = 5
|
|
)]
|
|
pub db_max_connections: u32,
|
|
|
|
/// Default UI + content-authoring language for this instance (i18n key, e.g. "sv").
|
|
#[arg(
|
|
long = "default-language",
|
|
env = "DEFAULT_LANGUAGE",
|
|
default_value = "sv"
|
|
)]
|
|
pub default_language: String,
|
|
|
|
/// Default display timezone (IANA name, e.g. "Europe/Stockholm"). Storage stays UTC;
|
|
/// this is a display hint surfaced to clients (and, later, server-side renderers).
|
|
#[arg(
|
|
long = "default-timezone",
|
|
env = "DEFAULT_TIMEZONE",
|
|
default_value = "Europe/Stockholm"
|
|
)]
|
|
pub default_timezone: String,
|
|
}
|