Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

crap.config

Read-only access to crap.toml configuration values using dot notation.

Functions

crap.config.get(key)

Get a configuration value by dot-separated key path.

Parameters:

  • key (string) — Dot-separated config key (e.g., "server.admin_port").

Returns: any — The value at that key path, or nil if the path doesn’t exist.

local port = crap.config.get("server.admin_port")   -- 3000
local host = crap.config.get("server.host")          -- "0.0.0.0"
local dev = crap.config.get("admin.dev_mode")        -- false
local depth = crap.config.get("depth.max_depth")     -- 10
local expiry = crap.config.get("auth.token_expiry")  -- 7200

Available Keys

The config structure mirrors crap.toml:

KeyTypeDefault
server.admin_portinteger3000
server.grpc_portinteger50051
server.hoststring“0.0.0.0”
database.pathstring“data/crap.db”
admin.dev_modebooleanfalse
auth.secretstring“”
auth.token_expiryinteger7200
depth.default_depthinteger1
depth.max_depthinteger10
upload.max_file_sizeinteger52428800
hooks.on_initstring[][]
hooks.max_depthinteger3
hooks.vm_pool_sizeinteger(auto)
hooks.max_instructionsinteger10000000
hooks.max_memoryinteger52428800
hooks.allow_private_networksbooleanfalse
hooks.http_max_response_bytesinteger10485760
pagination.default_limitinteger20
pagination.max_limitinteger1000
pagination.modestring“page”
locale.default_localestring“en”
locale.localesstring[][]
locale.fallbackbooleantrue
email.smtp_hoststring“”
live.enabledbooleantrue
access.default_denybooleanfalse

All sections from crap.toml are available — this table is not exhaustive. The entire CrapConfig struct is serialized to Lua.

Notes

  • Values are a read-only snapshot taken at VM creation time. Changes to crap.toml after startup won’t be reflected until the process restarts.
  • Available in both init.lua and hooks.
  • Returns nil for non-existent keys (never errors).