{"HOST":"","_config":{"name":"renderer","base_url":"https://lightswitch.jeffreybue.com","paths":{"assetsFolder":"/assets/","assetsRoute":"/_/","storageFolder":"","storageRoute":"/_/storage/","downloadsRoute":"/downloads/","downloadsFolder":"","partials":"/src/partials/index.js","templates":"/src/templates/index.js","markdown":"/src/markdown/index.js","tables":"/src/tables/index.js","mustache":"/utils/hooks/mustacheFunctions.js","apiDataTrx":"/utils/hooks/apiDataTrx.js","states":"/utils/lib/states.js"},"hosts":["localhost","www.localhost","127.0.0.1","lightswitch.jeffreybue.com"],"environment_switch":"development","endpoints":{},"routes":[{"host":"","path":"/","template":"home"},{"host":"","path":"/about/?","template":"about"}],"404pagetypes":[]},"assetsDate":{"css":"v=20261125T134823","js":"v=20261125T135015"},"urlprops":{"pathname":"/about/","pagetype":"about","params":null,"query":{"api":"true"}},"isMobile":false,"isDev":true,"statesArray":[{"abbr":"ALL","display":"All States"},{"abbr":"AL","display":"Alabama"},{"abbr":"AK","display":"Alaska"},{"abbr":"AZ","display":"Arizona"},{"abbr":"AR","display":"Arkansas"},{"abbr":"CA","display":"California"},{"abbr":"CO","display":"Colorado"},{"abbr":"CT","display":"Connecticut"},{"abbr":"DE","display":"Delaware"},{"abbr":"DC","display":"District Of Columbia"},{"abbr":"FL","display":"Florida"},{"abbr":"GA","display":"Georgia"},{"abbr":"HI","display":"Hawaii"},{"abbr":"ID","display":"Idaho"},{"abbr":"IL","display":"Illinois"},{"abbr":"IN","display":"Indiana"},{"abbr":"IA","display":"Iowa"},{"abbr":"KS","display":"Kansas"},{"abbr":"KY","display":"Kentucky"},{"abbr":"LA","display":"Louisiana"},{"abbr":"ME","display":"Maine"},{"abbr":"MD","display":"Maryland"},{"abbr":"MA","display":"Massachusetts"},{"abbr":"MI","display":"Michigan"},{"abbr":"MN","display":"Minnesota"},{"abbr":"MS","display":"Mississippi"},{"abbr":"MO","display":"Missouri"},{"abbr":"MT","display":"Montana"},{"abbr":"NE","display":"Nebraska"},{"abbr":"NV","display":"Nevada"},{"abbr":"NH","display":"New Hampshire"},{"abbr":"NJ","display":"New Jersey"},{"abbr":"NM","display":"New Mexico"},{"abbr":"NY","display":"New York"},{"abbr":"NC","display":"North Carolina"},{"abbr":"ND","display":"North Dakota"},{"abbr":"OH","display":"Ohio"},{"abbr":"OK","display":"Oklahoma"},{"abbr":"OR","display":"Oregon"},{"abbr":"PA","display":"Pennsylvania"},{"abbr":"RI","display":"Rhode Island"},{"abbr":"SC","display":"South Carolina"},{"abbr":"SD","display":"South Dakota"},{"abbr":"TN","display":"Tennessee"},{"abbr":"TX","display":"Texas"},{"abbr":"UT","display":"Utah"},{"abbr":"VT","display":"Vermont"},{"abbr":"VI","display":"Virgin Islands"},{"abbr":"VA","display":"Virginia"},{"abbr":"WA","display":"Washington"},{"abbr":"WV","display":"West Virginia"},{"abbr":"WI","display":"Wisconsin"},{"abbr":"WY","display":"Wyoming"}],"cloudFlareHeaders":{"cfRay":"a60da9658a7f1b3f-CMH","connectingIp":"216.73.216.91","country":"US","forwardedFor":"216.73.216.91,162.159.114.54"},"allHeaders":{"host":"lightswitch.jeffreybue.com","x-forwarded-for":"216.73.216.91,162.159.114.54","user-agent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","accept":"*/*","cf-ray":"a60da9658a7f1b3f-CMH","cdn-loop":"cloudflare; loops=1","cf-connecting-ip":"216.73.216.91","cf-ipcountry":"US","cf-visitor":"{\"scheme\":\"https\"}","x-forwarded-proto":"https","x-cloud-trace-context":"e7f11e00b16980daf33fbbb69e62751c/369229241725218031;o=1","traceparent":"00-e7f11e00b16980daf33fbbb69e62751c-051fc40a01b7ecef-01","forwarded":"for=\"162.159.114.54\";proto=https","accept-encoding":"gzip, br"},"states":{"ALL":"All States","AL":"Alabama","AK":"Alaska","AZ":"Arizona","AR":"Arkansas","CA":"California","CO":"Colorado","CT":"Connecticut","DE":"Delaware","DC":"District Of Columbia","FL":"Florida","GA":"Georgia","HI":"Hawaii","ID":"Idaho","IL":"Illinois","IN":"Indiana","IA":"Iowa","KS":"Kansas","KY":"Kentucky","LA":"Louisiana","ME":"Maine","MD":"Maryland","MA":"Massachusetts","MI":"Michigan","MN":"Minnesota","MS":"Mississippi","MO":"Missouri","MT":"Montana","NE":"Nebraska","NV":"Nevada","NH":"New Hampshire","NJ":"New Jersey","NM":"New Mexico","NY":"New York","NC":"North Carolina","ND":"North Dakota","OH":"Ohio","OK":"Oklahoma","OR":"Oregon","PA":"Pennsylvania","RI":"Rhode Island","SC":"South Carolina","SD":"South Dakota","TN":"Tennessee","TX":"Texas","UT":"Utah","VT":"Vermont","VI":"Virgin Islands","VA":"Virginia","WA":"Washington","WV":"West Virginia","WI":"Wisconsin","WY":"Wyoming"},"principles":[{"num":"01","title":"Flip the switch, ship the page","text":"The renderer has one job: turn a request into HTML as directly as possible. Every feature — routing, data, experiments — exists only because a real page needed it."},{"num":"02","title":"Convention over ceremony","text":"A page is a template file, a line in a registry, and a route. Content is a Markdown file. A dataset is a CSV. If you can name the file, you can find the behaviour."},{"num":"03","title":"The data object is the contract","text":"Templates never fetch, guess, or compute. Everything a page may need is assembled upstream into one inspectable object — and ?api=true shows it to you verbatim."},{"num":"04","title":"Simple surface, honest depths","text":"YAML and Mustache on the surface; regex routing, encrypted API payloads and deterministic hashing underneath. Start in minutes, go as deep as the problem demands."}],"deepDive":[{"name":"hosts","tag":"Allow-list","text":"config.js hosts is a hard allow-list (localhost, www.localhost, 127.0.0.1 here). An unlisted hostname 404s before routing — even for routes with host: \"\". A non-empty route host is a regex, e.g. \"www.example.com|staging.example.com\", for multi-brand serving from one deploy."},{"name":"path regex","tag":"Routing","text":"Route paths are full-path regex anchored with ^…$. Named groups (?<slug>[a-z0-9-]+) become data.urlprops.params — an array of single-key objects the template and loaders can read. template: \"statusChange\" skips rendering entirely and throws route.status (410 Gone, say)."},{"name":"endpoints","tag":"Data APIs","text":"A route opts into data with \"endpoint\": \"<key>\". The fetch URL is endpoints[key][ENVIRONMENT] + \"/\" + data_version + path — the browser path and API path are 1:1. Endpoint headers merge with route headers (route wins). ENVIRONMENT follows config environment_switch only while API_VIEW_FLAG=true; otherwise it is production."},{"name":"KRYPTOPASS","tag":"Encryption","text":"A text/plain API body is AES-decrypted before JSON.parse — either iv:ciphertext (SHA-256 key, CBC) or legacy CryptoJS format. Unset KRYPTOPASS only logs a warning; the server still starts. A non-200 upstream becomes an HttpError, except 404, which hands the body to the error page as commonNames — \"possible matches\" — and falls through."},{"name":"data loaders","tag":"Hooks","text":"utils/hooks/apiDataTrx.js maps pagetype → loader list. Loaders run in order, mutate data in place, and may set data.recordCount for logging. HttpError from a loader always reaches errorHandler; other errors are logged and swallowed unless the template joins STRICT_TEMPLATES. Mustache lambda helpers (dates, case, slugs, state lookup, formatCount, ifEquals…) attach before loaders run."},{"name":"variations","tag":"Experiments","text":"Cookie variations assign control/variant randomly, persist 30 days in a sha256(path) cookie, and share one cookie across route_groups with identical path strings. Bucket tests skip cookies entirely: hash(path) % templates.length is stable per URL. template_rules run last — first matching when wins, e.g. singleRecord when data.persons.length === 1."},{"name":"storage","tag":"Idle, ready","text":"Ported from renderer_different and switched off until paths.storageFolder points at a public bucket. assetHandler proxies /_/storage/…, downloadHandler serves flat, sanitised PDF filenames from /downloads/. Traversal (.. , backslashes, escaping URLs) is rejected and an upstream 403 reads as 404."},{"name":"logging","tag":"Observability","text":"loggingHandler writes a structured log on response finish (skipping assets and health checks), the head partial pushes variation/bucket payloads to dataLayer, and the client logger.js keeps a 2-year visitorid, first/last-touch attribution, and beacons actions to POST /seo-tracking/ (204). The error handler renders error.html — and arms a 404 beacon."}],"addPageSteps":[{"n":"STEP 01","title":"Write the template","text":"Create src/templates/about.html — YAML front matter above a --yaml-- line, Mustache and shared partials below."},{"n":"STEP 02","title":"Register it","text":"Add one import and one key in src/templates/index.js. The key is the name routes will reference."},{"n":"STEP 03","title":"Add the route","text":"In config.js: { \"host\": \"\", \"path\": \"/about/?\", \"template\": \"about\" }. Named regex groups become URL params automatically."},{"n":"STEP 04","title":"Load its data","text":"Optional: add utils/hooks/data_loaders/about.js and register it in apiDataTrx.js — exactly how this page feeds its own sections."}],"faqs":[{"q":"Do I need to restart after editing a template or partial?","a":"Yes for templates, partials, Markdown and tables — those files are read once at process start and cached. In local dev nodemon (npm run dev) restarts for you on any file change. Less and client JS are handled separately by the running Gulp watcher, which also bumps the CSSDATE/JSDATE cache-busters in server/globals.js."},{"q":"How do I see exactly what data a template received?","a":"Run locally with API_VIEW_FLAG=true (the default in Docker) and append ?api=true to any URL. You get the full data object as JSON — API payload, urlprops, states, Cloudflare headers and loader additions — minus the Mustache lambda functions."},{"q":"What happens when the API is down or returns an error?","a":"A non-200 upstream becomes an HttpError and renders the error template with the right status — except a 404, whose body is treated as suggested matches (commonNames) and shown on the error page. If the chosen template is listed in 404pagetypes and the API returned nothing, the response is a clean 404."},{"q":"Which experiment should I use — variation or bucket test?","a":"Use a cookie variation for a classic visitor-level A/B test (same person, same variant, 30 days). Use a bucket test when the URL itself should decide — every visit to that URL, from anyone, renders the same variant because it is hashed from the path. template_rules sit above both when the data, not the visitor, should decide."},{"q":"Is the storage / downloads system live on this site?","a":"Not yet. It is fully ported and tested in sibling renderers, but paths.storageFolder is \"\" in config.js, so neither /_/storage/ nor /downloads/ is mounted. Point it at a public bucket URL and both routes switch on — they are registered before the static asset handler precisely so they win over /_/."},{"q":"Why Mustache instead of a bigger templating engine?","a":"Because the renderer pushes complexity upstream into data loaders, where it is testable JavaScript, and keeps templates logic-light: variables, sections, partials and a small set of lambda helpers. Writers and designers can edit HTML safely; engineers keep the sharp tools in code."}],"_content":{"markdown":{},"table":{},"_alltables":{},"_allmarkdown":{}},"title":"About — Light Switch, the Cloud Run Renderer","description":"Why Light Switch exists, the principles behind it, and the full engineering deep dive: middleware order, regex routing, data loaders, encrypted APIs, experiments and storage.","h1":"Built to be understood."}