ordinary-config 0.9.1

Config for Ordinary
Documentation
// Copyright (C) 2026 Ordinary Labs, LLC.
//
// SPDX-License-Identifier: AGPL-3.0-only

pub mod limits;
pub use limits::*;

use serde::{Deserialize, Serialize};

fn default_env_name() -> String {
    "development".to_string()
}
fn default_invite_token_link() -> String {
    "/".to_string()
}

/// Config definition for an Ordinary API Instance
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[cfg_attr(feature = "docs", derive(schemars::JsonSchema))]
#[derive(Deserialize, Serialize, Clone)]
pub struct OrdinaryApiConfig {
    pub domain: String,
    pub contacts: Vec<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub public_dns_ip: Option<[u8; 4]>,
    #[serde(default = "default_env_name")]
    pub env_name: String,
    #[serde(default)]
    pub limits: OrdinaryApiLimits,
    #[serde(default)]
    pub proxied_metrics: Vec<ProxiedMetric>,
    /// whether to serve the web console
    #[serde(default)]
    pub console: bool,
    /// link to the location where you are able to obtain an invite token
    #[serde(default = "default_invite_token_link")]
    pub invite_token_link: String,
}

#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[cfg_attr(feature = "docs", derive(schemars::JsonSchema))]
#[derive(Deserialize, Serialize, Clone)]
pub struct ProxiedMetric {
    pub name: String,
    pub endpoint: String,
}