Rustelo/resources/nickel/server/contracts.ncl
Jesús Pérez f1010e9d07
chore: update
2026-07-18 20:16:16 +01:00

243 lines
5.2 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Server runtime configuration contracts
#
# Mirrors the Rust structs in rustelo_server/src/config/defs.rs.
# These contracts validate server, session, CORS, static files,
# directories, app, logging, redis, routing, cache, and RBAC path.
{
ServerConfig = {
protocol
| String
| doc "HTTP protocol: 'http' or 'https'"
| default = "http",
host
| String
| doc "Server bind address"
| default = "0.0.0.0",
port
| Number
| doc "Server port (165535)"
| default = 3030,
environment
| String
| doc "Runtime environment: 'development' or 'production'"
| default = "development",
log_level
| String
| doc "Log level: trace, debug, info, warn, error"
| default = "info",
},
SessionConfig = {
secret
| String
| doc "Session secret key — use '${SESSION_SECRET}' to read from env",
cookie_name
| String
| default = "session_id",
cookie_secure
| Bool
| doc "Require HTTPS for session cookies — set true in production"
| default = false,
cookie_http_only
| Bool
| default = true,
cookie_same_site
| String
| doc "SameSite policy: 'lax', 'strict', or 'none'"
| default = "lax",
max_age
| Number
| doc "Session lifetime in seconds"
| default = 3600,
},
CorsConfig = {
allowed_origins
| Array String
| default = ["http://localhost:3030"],
allowed_methods
| Array String
| default = ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
allowed_headers
| Array String
| default = ["Content-Type", "Authorization", "X-Requested-With"],
allow_credentials
| Bool
| default = true,
max_age
| Number
| doc "CORS preflight cache duration in seconds"
| default = 3600,
},
StaticFilesConfig = {
assets_dir
| String
| doc "Static assets directory (relative to root_path)"
| default = "public",
site_root
| String
| doc "cargo-leptos output directory"
| default = "target/site",
site_pkg_dir
| String
| doc "WASM/JS package subdirectory under site_root"
| default = "pkg",
},
ServerDirConfig = {
public_dir | String | default = "public",
uploads_dir | String | default = "uploads",
logs_dir | String | default = "logs",
temp_dir | String | default = "tmp",
cache_dir | String | default = "cache",
config_dir | String | default = "config",
data_dir | String | default = "data",
backup_dir | String | default = "backups",
template_dir | String | optional,
},
AppConfig = {
name
| String
| default = "Website",
version
| String
| default = "0.1.0",
debug
| Bool
| default = true,
enable_metrics
| Bool
| default = false,
enable_health_check
| Bool
| default = true,
enable_compression
| Bool
| default = true,
max_request_size
| Number
| doc "Maximum request body size in bytes"
| default = 10485760,
admin_email
| String
| optional,
},
LoggingConfig = {
format
| String
| doc "Log format: 'pretty' (dev) or 'json' (prod)"
| default = "pretty",
level
| String
| default = "debug",
file_path
| String
| default = "logs/app.log",
max_file_size
| Number
| doc "Log rotation threshold in bytes"
| default = 10485760,
max_files
| Number
| doc "Maximum rotated log files to keep"
| default = 5,
enable_console
| Bool
| default = true,
enable_file
| Bool
| default = false,
},
RedisConfig = {
enabled | Bool | default = false,
url | String | default = "redis://localhost:6379",
pool_size | Number | default = 10,
connection_timeout | Number | default = 5,
command_timeout | Number | default = 5,
},
RoutingConfig = {
enable_tracking | Bool | optional,
tracking_log_path | String | optional,
max_events_in_memory | Number | optional,
slow_resolution_threshold_ms | Number | optional,
enable_console_debug | Bool | optional,
cache_max_entries | Number | optional,
cache_ttl_seconds | Number | optional,
},
CacheConfig = {
persistent_enabled
| Bool
| default = false,
memory_enabled
| Bool
| default = true,
memory_max_size
| Number
| doc "Memory cache capacity in bytes"
| default = 104857600,
memory_ttl
| Number
| doc "Memory cache TTL in seconds"
| default = 3600,
persistent_ttl
| Number
| doc "Persistent cache TTL in seconds"
| default = 86400,
persistent_max_size
| Number
| doc "Persistent cache max size in bytes"
| default = 1073741824,
persistent_cleanup_interval
| Number
| doc "Cleanup task interval in seconds"
| default = 3600,
},
RbacNclConfig = {
ncl_path
| String
| doc "Path to rbac.ncl policy file (hot-reloadable)"
| default = "site/rbac.ncl",
},
}