#![deny(clippy::await_holding_lock)]
mod access_keys;
mod cors;
mod http;
mod json;
mod mcp;
mod mcp_tasks;
mod subscribe;
#[cfg(feature = "tls")]
pub mod tls;
mod ws;
use mushroomdb::{AccessKeys, MutationEvent, SharedDb};
pub use http::{
register_backup_metrics, register_bolt_metrics, BackupMetrics, BoltMetrics, TxLimits,
TX_MAX_ENV, TX_MAX_LIFETIME_ENV, TX_TIMEOUT_ENV,
};
pub use mcp::{run_mcp_stdio, run_mcp_stdio_with, ASSOCIATION_TOOLS};
pub const LOG_TARGET_ROOT: &str = module_path!();
#[derive(Clone, Debug)]
pub(crate) enum AuthIdentity {
Full,
Write,
Role(String),
Anonymous,
}
#[derive(Clone, Copy, Debug)]
pub(crate) struct ReadOnlyKey;
#[derive(Clone)]
struct AppState {
db: SharedDb,
watch: tokio::sync::broadcast::Sender<MutationEvent>,
token: Option<String>,
role_tokens: std::collections::HashMap<String, String>,
access_keys: Option<AccessKeys>,
addr: std::net::SocketAddr,
tls_active: bool,
started_at: std::time::Instant,
started_unix_s: u64,
ready: std::sync::Arc<std::sync::atomic::AtomicBool>,
txs: http::TxStore,
}
pub use access_keys::watch_sighup;
pub use cors::{cors_layer_from_env, parse_cors_origins, CORS_ORIGINS_ENV};
#[allow(deprecated)]
pub use http::{
router, router_with_access_keys, router_with_auth, router_with_cors, router_with_ready_flag,
router_with_role_tokens, router_with_tx_limits, router_with_ui, router_with_ui_tls, serve,
serve_with_role_tokens, serve_with_role_tokens_and_shutdown,
serve_with_role_tokens_and_shutdown_with_ready_flag, serve_with_shutdown, serve_with_ui,
serve_with_ui_and_role_tokens, serve_with_ui_and_role_tokens_and_shutdown,
serve_with_ui_and_role_tokens_and_shutdown_with_ready_flag,
};
#[cfg(feature = "embed-ui")]
pub use http::{
router_with_embedded_ui, serve_with_embedded_ui, serve_with_embedded_ui_and_shutdown,
serve_with_embedded_ui_and_shutdown_with_ready_flag,
};
#[cfg(feature = "tls")]
pub use http::{serve_tls, serve_tls_with_shutdown, serve_tls_with_shutdown_with_ready_flag};
#[cfg(feature = "tls")]
pub use tls::load_server_config;