Setup
Everything you need to clone, install, and serve Moxie API locally.
Prerequisites
| Tool | Version | Notes |
|---|---|---|
| Node.js | 22 (see .nvmrc) |
Use nvm or fnm to manage versions |
| Yarn | 1.x (Classic) | npm is blocked — the repo enforces Yarn via a preinstall script |
| Git | Any recent | GitHub SSH access to foxnews/fn-moxie-api |
Tip: If you use nvm, running
nvm usein the repo root will pick up the.nvmrcautomatically.
Clone & install
git clone [email protected]:foxnews/fn-moxie-api.git
cd fn-moxie-api
nvm use # or fnm use
yarn install
yarn install pulls all dependencies and sets up the local moxie CLI binary.
Start the local server
yarn dev
This runs Webpack in watch mode and starts a local webserver on port 3001. It targets dev backend data by default.
Smoke test: open http://localhost:3001/fn/hello — you should get a JSON response.
Environment variants
| Command | Backend data |
|---|---|
yarn dev |
dev |
yarn dev:stage |
stage |
yarn dev:prod |
prod |
yarn dev:debug |
dev + Node --inspect |
yarn dev:clean |
dev (cleans build/dist first) |
yarn dev:tunnel |
dev + Unmoxed tunnel |
Aliases like yarn local:dev, yarn serve:dev resolve to the same entry point.
Environment variables
Most local development works out of the box. build/configs/env.js supplies Brightcove tokens and other defaults so video endpoints work without extra configuration.
Optional .env entries:
| Variable | Purpose |
|---|---|
MOXIE_ENV |
Force dev, stage, or prod (defaults to dev) |
UNMOXED |
Enable local-dev mode that bypasses CDN checks |
UNMOXED_SERVER |
Point the tunnel client at a local unmoxed-server (e.g. http://localhost:3099) |
UNMOXED_TOKEN |
Bearer token for remote tunnel server JWT auth |
You can also override the data environment per-request with ?env=dev|stage|prod.
Build & test
yarn build # Production Webpack build
yarn build:dev # Dev build
yarn build:stage # Stage build
yarn test # Run Jest tests
yarn lint # Biome check on src/
yarn lint:fix # Biome check + auto-fix
yarn format # Biome format src/ and build/
Project structure (abridged)
src/
├── index.ts # Lambda handler entry point
├── moxie/ # Core framework (Moxie, Setup, Router, Storage, etc.)
├── apis/ # Endpoint implementations by brand
│ ├── foxnews/
│ ├── foxbusiness/
│ ├── foxweather/
│ ├── outkick/
│ └── shared/ # Cross-brand endpoints
├── frameworks/ # Execution frameworks (jsonapi, template, mobile.tab, etc.)
└── settings/ # Routes, environments, caching policies, specs
build/
├── configs/ # Webpack config, local env defaults
├── scripts/ # Build and dev scripts
└── webserver.js # Local dev server
tf/ # Terraform infrastructure
├── main.tf
├── variables.tf
└── envs/ # Per-environment tfvars and backend config
static/public/ # Static assets synced to S3
Request flow (at a glance)
- Request arrives →
src/index.ts(Lambda handler) - Setup (
src/moxie/lib/Setup.ts) initializes themoxieglobal - Moxie (
src/moxie/lib/Moxie.ts) parses the request, resolves identity & settings - Router (
src/moxie/libraries/modules/router.js) matches the route and loads the handler - Handler returns data → response is formatted and sent
The first path segment determines the site: fn → foxnews, fb → foxbusiness, fw → foxweather, ok → outkick.
Debugging
Append ?debugga=<flag> to any request URL for debug output:
| Flag | Shows |
|---|---|
setup:request |
Parsed request details |
setup:identity |
Resolved site identity |
routes |
Route matching info |
config |
Merged config for matched route |
mapping |
JSON:API mapping resolution |
source.url |
Upstream API URL being called |
Full list: Debugging reference.
Next steps
- Local development — everyday Yarn commands and runtime query helpers
- Architecture — deeper look at the request pipeline
- Cookbook: new endpoint — build your first endpoint
- Unmoxed & tunnels — expose your local server via tunnel