Frameworks & endpoint patterns
Handlers are usually thin: they delegate to a framework or extend @app/frameworks/jsonapi. Keep orchestration in index.js and put shaping in config/mapping.
JSON API (most common)
| File | Role |
|---|---|
index.js |
Handler — typically extends jsonapi framework |
config.js |
Querystring defaults + querystrings.options (string, number, csv, boolean, rewrite) |
mapping.js |
Declarative mapping: map, compute, group, static, rewrite, pluck, parse |
helpers/compute.js |
Functions referenced from mapping.compute or mapping.parse.execute |
helpers/querystrings.js |
Map route query params → backend request params |
Variable-specific routes can override with nested config.js / mapping.js.
Template (RSS, XML, HTML)
Used for feeds and templated text responses.
| File | Role |
|---|---|
config.js |
sources (type: 'moxie' | 'static'), pluck/mapping, optional middleware |
template.dot |
doT template; override with ?template=name → name.dot |
Mobile tab (mobile.tab)
Config-only screens: config.properties (screen + meta) and config.order (ordered components and feeds). Used for tabs like Listen (FN) and For You (FB).
Mobile Spark tab (mobile.spark.tab)
Loads Spark CMS layouts, resolves regions/components, applies mods, optional inject.js for ads and hardcoded items. Heavily used by Fox Weather mobile home/read.
Mobile OTT (mobile.ott)
Versioned OTT config; Fox News OTT often uses dedicated endpoint index.js instead of the bare framework.
Staticish
Simple JSON (or text) with token replacement such as [[site]], [[prefix]].
Import convention
utils.import(...) uses the first export and warns on multiple exports — prefer one export per module for endpoint files.
Debugging by framework
Use ?debugga=... on requests (comma-separated flags allowed):
| Area | Useful flags |
|---|---|
| Router / setup | route, config, setup:request, setup:identity, setup:settings |
| JSON API | mapping, compute, source, request.querystrings |
| Template | inputs, template |
See Debugging for a fuller list.
See also
- JSON:API mapping guide — deep dive on
mapping.js - Template & doT —
config.sourcesandtemplate.dot - Mobile platform guide — FN / FB / FW surfaces
- Documentation map — full site index