ob:config & config.toml (12-Factor Runtime Config)¶
Orbita separates build/project metadata from runtime environment settings:
ob.toml— project manifest (name, version, dependencies,[embed]). Committed to Git and baked into compiled binaries.config.toml— runtime configuration (server host/port, SQLite database path, custom app settings). Can be changed per environment (dev, staging, production) without recompiling.
Example config.toml¶
[server]
host = "127.0.0.1"
port = 3000
[database]
path = "storage/app.db"
[app]
name = "Orbita Todo"
items_per_page = 25
12-Factor Precedence¶
Runtime settings are resolved automatically in the following order (highest priority first):
- Environment variables
HOST(overrides[server].host)PORT(overrides[server].port)ORBITA_DB(overrides[database].path)config.tomlin the project directory (or working directory of a compiled binary)- Built-in defaults
server.host="127.0.0.1"server.port=3000database.path="storage/app.db"
Both
http.serve(handler)(1-argument form) anddb.default()read this configuration automatically, so you can deploy the exact same binary across environments usingHOST,PORT, andORBITA_DB.
Lua API (ob:config)¶
local config = require("ob:config")
local srv = config.server() -- { host = "127.0.0.1", port = 3000 }
local db_cfg = config.database() -- { path = "storage/app.db" }
local all = config.all() -- full parsed config.toml table
print("Listening on", srv.host .. ":" .. srv.port)
print("Database:", db_cfg.path)
print("App name:", all.app and all.app.name or "Default")
| Function | Return Value |
|---|---|
config.server() |
{ host: string, port: number } (with HOST/PORT env overrides applied) |
config.database() |
{ path: string } (with ORBITA_DB env override applied) |
config.all() |
Full table parsed from config.toml (or {} if the file does not exist) |