Code conventions
Naming
snake_casefor internal variables, functions, and object properties you control.camelCaseonly where it matches external APIs (AWS, Brightcove, client payloads, etc.).
Colors (mobile / JSON payloads)
Hex colors must be RGB or RGBA. Do not use ARGB — clients adapt as needed.
Errors
- Use
moxie.throw()for structured MoxieError data. - Use
generate.crash()for shaped error responses where that helper applies. - Top-level
src/index.tscatches errors and returns API Gateway–compatible output.
Logging
- Use
moxie.log(type, message, body, include_benchmox)— avoidconsole.log()(Biome / hooks discourage it).
Request context
const { moxie } = global
const request = moxie.request // method, path, body, querystrings, headers
const identity = moxie.identity // site, path, env, flags, urls, hosts
const settings = moxie.settings // routes, sites, env, caching, specs
Endpoint design
- Keep
index.jsthin: orchestration only. - Put query validation in
config.jsviaquerystrings.optionswhen possible — avoid duplicating the same rules in the handler. - Prefer declarative
mapping.jsover imperative field copying for JSON:API endpoints.
TypeScript
- Target ES2020, CommonJS,
@app→./src(seetsconfig.json). - Strict mode is off in this repo — still prefer clear types on new TS code where practical.