website-htmx-rustelo-code/site/config/server.ncl
2026-07-10 03:44:13 +01:00

103 lines
3 KiB
Text

# Server runtime configuration
#
# HTTP server, session, CORS, static files, directory layout, application
# metadata, logging, Redis, routing analytics, and response cache.
#
# Sensitive values use '${ENV_VAR}' tokens — resolved by the Rust config
# loader after deserialization. Set real values in .env (never commit them).
let C = import "server/contracts.ncl" in
{
server = {
protocol = "http",
host = "0.0.0.0",
port = 3030,
environment = "production",
log_level = "info",
} | C.ServerConfig,
session = {
secret = "${SESSION_SECRET}",
cookie_name = "session_id",
cookie_secure = false,
cookie_http_only = true,
cookie_same_site = "lax",
max_age = 3600,
} | C.SessionConfig,
cors = {
allowed_origins = ["http://localhost:3030", "http://127.0.0.1:3030"],
allowed_methods = ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
allowed_headers = ["Content-Type", "Authorization", "X-Requested-With"],
allow_credentials = true,
max_age = 3600,
} | C.CorsConfig,
# Quoted key required — 'static' is a Nickel keyword.
"static" = {
assets_dir = "site/public",
site_root = "site",
site_pkg_dir = "pkg",
} | C.StaticFilesConfig,
server_dirs = {
public_dir = "site/public",
uploads_dir = "uploads",
logs_dir = "works-pv/logs",
temp_dir = "works-pv/tmp",
cache_dir = "works-pv/cache",
config_dir = "config",
data_dir = "works-pv/data",
backup_dir = "backups",
} | C.ServerDirConfig,
app = {
name = "Website",
version = "0.1.0",
debug = true,
enable_metrics = false,
enable_health_check = true,
enable_compression = true,
max_request_size = 10485760,
admin_email = "admin@ontoref.dev",
} | C.AppConfig,
logging = {
format = "pretty",
level = "debug",
file_path = "works-pv/logs/app.log",
max_file_size = 10485760,
max_files = 5,
enable_console = true,
enable_file = true,
} | C.LoggingConfig,
redis = {
enabled = false,
url = "redis://localhost:6379",
pool_size = 10,
connection_timeout = 5,
command_timeout = 5,
} | C.RedisConfig,
routing = {
enable_tracking = true,
tracking_log_path = "works-pv/logs/navigation.jsonl",
max_events_in_memory = 1000,
slow_resolution_threshold_ms = 10,
enable_console_debug = true,
cache_max_entries = 1000,
cache_ttl_seconds = 3600,
} | C.RoutingConfig,
cache = {
persistent_enabled = false,
memory_enabled = true,
memory_max_size = 104857600,
memory_ttl = 3600,
persistent_ttl = 86400,
persistent_max_size = 1073741824,
persistent_cleanup_interval = 3600,
} | C.CacheConfig,
}