Cloud Run Renderer · crr_renderer

Flip the switch.
Ship the page.

Light Switch is a lightweight HTML & Mustache renderer that turns a request into a finished page in one clean pass — route, data, template, done. No heavy framework between your content and the browser. No build step between an idea and a live URL.

$ docker-compose up --build  → http://localhost:8787

lightswitch — zsh
➜ ~ docker-compose up --build
# image: crr-renderer · PORT=8787
✓ redirects loaded (redirects.json)
✓ templates registered home · about
✓ partials loaded HEAD · HEADER · FOOTER · FOOT
→ GET / ······ 200 · home · rendered
→ GET /about/ ·· 200 · about · rendered
➜ ~
Express 5 server Mustache templates Markdown + CSV content Gulp Less / JS
0
Middleware stages per request
route → render
0
Hard request timeout
connect-timeout
0
Experiment systems built in
cookie + bucket
0
Command to run everything
docker-compose up
The simple idea

A page is just three things
agreeing with each other.

That is the whole mental model. If you can hold these three ideas, you already understand Light Switch — everything else is refinement.

01 · Route
🧭

A route says where

A line in config.js pairs a URL pattern with a template: / → home, /about/ → about. Patterns are regex, so /(?<state>\w+)/ quietly hands the page a state value to work with.

02 · Data
🗂️

Data says what

Before anything renders, the framework assembles one data object: API results, YAML typed at the top of the template, Markdown articles, CSV tables, even the visitor's Cloudflare geo headers. One place, everything a page could need.

03 · Template
🎨

A template says how it looks

Plain HTML with Mustache's friendly curly braces — {{title}} drops a value in, {{> HEADER}} reuses a shared partial. Designers edit it safely; nothing in it can crash the server.

Under the hood · interactive

Follow one request
through eight doors.

Every request walks the same middleware pipeline registered in server/app.js. Click each stage — this is the exact journey from browser to rendered HTML, in order.

Redirects first

redirects.json → routeHandler.checkRedirects

Before any route matches, the request is checked against redirects.json. Patterns are full-path regex (301 or 302), the query string is preserved, and a hit short-circuits everything downstream. Try it: /example-redirect/ lands right back here.

The framework

Small surface.
Serious machinery.

Six systems do the heavy lifting, each switched on by a line of config — and each idle until you ask for it. This very page is rendered by them: its stats, pipeline and cards are fed by a data loader, not hand-typed HTML.

Routing
🧭

Regex routes, human URLs

Host and path are plain regex in config.js. Named capture groups flow straight into the page data, so /california/ and /articles/my-post/ need no router code at all.

Data
🗂️

One data object per page

API payload, YAML front matter, Markdown, CSV tables, states and Cloudflare geo — merged into a single object your template simply reads from. What you see at ?api=true is what the template got.

Experiments
🧪

Two ways to test, zero setup

Cookie variations for classic A/B splits and deterministic bucket tests for URL-stable variants. Both report into dataLayer and the /seo-tracking/ beacon automatically.

Content
✍️

Writers write Markdown

Drop a .md file in src/markdown, register it, and it renders as HTML in any template. CSVs become iterable tables the same way. No deploy pipeline for a comma.

Performance
⚡

Fast by construction

Above-the-fold CSS is inlined in the head, HTML whitespace is collapsed, assets are minified by Gulp with cache-busted URLs, and static files carry 30-day cache headers.

Safety
🛡️

Guardrails included

Host allow-list, 30-second timeout, staging basic-auth, AES-decrypted API bodies, path-traversal-proof storage proxying, and an error template that renders instead of leaking a stack.

Why it matters

Managers get momentum.
Engineers get the good stuff.

For managers & content teams

Pages stop being tickets and start being files. The path from idea to live URL is short, visible, and hard to break.

  • Launch pages without a release train — a template, a route, done.
  • Writers publish in Markdown, data teams drop in a CSV — no engineering in the loop.
  • Test before you commit — split traffic or bucket URLs, and watch results in your existing analytics.
  • One Docker command runs the whole thing, locally or on Cloud Run.

For engineers

Under the calm surface: a strict middleware pipeline with deterministic behaviour you can reason about — and debug with one query param.

  • Regex host + path routing with named groups landing in data.urlprops.params.
  • Per-template data loaders (apiDataTrx) that mutate one inspectable data object in order.
  • AES-decrypted API payloads, merged endpoint/route headers, 404-as-suggestions semantics.
  • Deterministic bucket hashing, cookie variations, and data-driven template_rules — layered in that order.
Go all the way down →
Taste of the code

Route → data → template.
That's the API.

Adding a page is declaring intent in three small places. This site added its About page in exactly these steps — the files below are real.

config.js — declare the route
// "" host = any allow-listed host { "host": "", "path": "/about/?", "template": "about" // "endpoint": "api_base_url", ← opt into data // "variations": ["aboutAlt"], ← opt into a test }
src/templates/about.html — YAML + Mustache
title: "About — Light Switch" h1: "Built to be understood." --yaml-- <h1>{{h1}}</h1> {{#principles}} <!-- loop loader data --> <h3>{{title}}</h3> {{/principles}}
Keep going

The simple version got you here.
The deep version is better.

Principles, the full middleware anatomy, encrypted endpoints, experiment layering, storage proxying — and the four steps to add your own page, documented on the page that used them.

Read the About page →