Skip to content

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):

  1. Environment variables
  2. HOST (overrides [server].host)
  3. PORT (overrides [server].port)
  4. ORBITA_DB (overrides [database].path)
  5. config.toml in the project directory (or working directory of a compiled binary)
  6. Built-in defaults
  7. server.host = "127.0.0.1"
  8. server.port = 3000
  9. database.path = "storage/app.db"

Both http.serve(handler) (1-argument form) and db.default() read this configuration automatically, so you can deploy the exact same binary across environments using HOST, PORT, and ORBITA_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)