Skip to main content

modo/config/
modo.rs

1use serde::Deserialize;
2
3/// Top-level framework configuration.
4///
5/// Deserializes from a YAML file loaded by [`crate::config::load`]. All fields
6/// use `#[serde(default)]`, so any section omitted from the YAML file falls
7/// back to the type's own `Default` implementation.
8///
9/// Applications that need extra config fields can embed `Config` with
10/// `#[serde(flatten)]` inside their own config struct.
11#[non_exhaustive]
12#[derive(Debug, Clone, Deserialize, Default)]
13#[serde(default)]
14pub struct Config {
15    /// HTTP server bind address and shutdown behaviour.
16    pub server: crate::server::Config,
17    /// libsql database settings. Requires the `db` feature.
18    #[cfg(feature = "db")]
19    #[serde(default)]
20    pub database: crate::db::Config,
21    /// Log level, format, and optional Sentry integration.
22    pub tracing: crate::tracing::Config,
23    /// Signed cookie secret and attributes. When absent, signed/private cookies
24    /// are disabled.
25    pub cookie: Option<crate::cookie::CookieConfig>,
26    /// HTTP security-header middleware settings.
27    pub security_headers: crate::middleware::SecurityHeadersConfig,
28    /// CORS policy.
29    pub cors: crate::middleware::CorsConfig,
30    /// CSRF protection settings.
31    pub csrf: crate::middleware::CsrfConfig,
32    /// Token-bucket rate-limiting settings.
33    pub rate_limit: crate::middleware::RateLimitConfig,
34    /// Session TTL, cookie name, fingerprint validation, touch interval, and
35    /// per-user session limit. Requires the `session` feature.
36    #[cfg(feature = "session")]
37    #[serde(default)]
38    pub session: crate::session::SessionConfig,
39    /// Background job queue settings. Requires the `job` feature.
40    #[cfg(feature = "job")]
41    #[serde(default)]
42    pub job: crate::job::JobConfig,
43    /// CIDR ranges of trusted reverse proxies used by [`crate::ip::ClientIpLayer`].
44    ///
45    /// Accepts any string parseable as [`ipnet::IpNet`], e.g. `"10.0.0.0/8"`.
46    #[serde(default)]
47    pub trusted_proxies: Vec<String>,
48    /// OAuth provider settings. Requires the `auth` feature.
49    #[cfg(feature = "auth")]
50    #[serde(default)]
51    pub oauth: crate::auth::oauth::OAuthConfig,
52    /// SMTP / email delivery settings. Requires the `email` feature.
53    #[cfg(feature = "email")]
54    #[serde(default)]
55    pub email: crate::email::EmailConfig,
56    /// MiniJinja template engine settings. Requires the `templates` feature.
57    #[cfg(feature = "templates")]
58    #[serde(default)]
59    pub template: crate::template::TemplateConfig,
60    /// MaxMind GeoIP database path and settings. Requires the `geolocation`
61    /// feature.
62    #[cfg(feature = "geolocation")]
63    #[serde(default)]
64    pub geolocation: crate::geolocation::GeolocationConfig,
65    /// S3-compatible storage bucket settings. Requires the `storage` feature.
66    #[cfg(feature = "storage")]
67    #[serde(default)]
68    pub storage: crate::storage::BucketConfig,
69    /// DNS verification settings. Requires the `dns` feature.
70    #[cfg(feature = "dns")]
71    #[serde(default)]
72    pub dns: crate::dns::DnsConfig,
73    /// API key module settings. Requires the `apikey` feature.
74    #[cfg(feature = "apikey")]
75    #[serde(default)]
76    pub apikey: crate::apikey::ApiKeyConfig,
77    /// JWT signing and validation settings. Requires the `auth` feature.
78    #[cfg(feature = "auth")]
79    #[serde(default)]
80    pub jwt: crate::auth::jwt::JwtConfig,
81}