CatoandClaude 0cad414fae fix(ask): hirnli's tenant names and a database error both reach the fallback; a smoke check for the running engine (#4)
The ask route refused any name classifyHost calls invalid, which includes
every <tenant>.hirnli.orangecat.ch (two labels under the base) - so pointing
Caddy's one ask at the engine would have stopped hirnli's certificates (the
install script's parity check would have refused the switch instead). And a
database error (tables not migrated, an outage) threw before the fallback was
asked. The decision is now mayIssue() in src/lib/ask.ts, tested without a
database.

scripts/smoke.mjs checks a running engine: health, the published site by its
free address and own domain, the preview (noindex), names nobody holds,
the ask, and a form refused for a missing field. Run locally against
Loki's 0140_sites.sql with a SELECT-only role: all checks pass.


Claude-Session: https://claude.ai/code/session_019MDtmugQS9ffkEryKtQb5c

Co-authored-by: Claude <noreply@anthropic.com>
2026-12-01 15:39:46 +01:00

sites

One engine for every bitbaum data site: a site that is a row in Loki's database, not a repository of its own. The engine picks the site by the request's domain, loads its published version, and renders it with @bitbaum/sitekit. Design: loki docs/architecture/adr/ADR-0001-the-sites-platform.md.

What it answers

Address Shows
<slug>.orangecat.ch the published version of the site with that slug
a customer's own domain the published version of the site it is verified for (site_domains)
sites.orangecat.ch/<site id>/… the working (preview) version, never indexed
localhost:<port>/ sites engine — the deploy's health probe
/_sites/ask?domain= Caddy's on-demand TLS check: 200 for a host this engine serves; any other well-formed name (hirnli's <tenant>.hirnli.orangecat.ch included) gets whatever SITES_ASK_FALLBACK (hirnli's tenant check) says, also when this engine cannot read its tables
/_sites/fonts/… the webfont files, copied from @bitbaum/design-tokens into public/ before each build

Everything else is a 404. A row that does not parse is a 404 and a log line, never a broken page.

What it never does

  • Write. It connects with a SELECT-only role. Loki is the only writer, so a Loki outage stops editing, not serving.
  • Know the app list. Apps keep their own Caddy blocks, which win over the wildcard; Loki refuses a site on an app's name.
  • Fetch a font from a third party.

Environment

Variable
SITES_DATABASE_URL Loki's database, as the read-only sites_reader role
SITES_BASE_DOMAIN default orangecat.ch
SITES_PREVIEW_HOST default sites.<base>
SITES_ASK_FALLBACK the ask URL Caddy used before (hirnli), for names this engine does not serve

Verify

pnpm run verify   # format, typecheck, lint, tests — what the merge check runs

Against a running engine (after a deploy, or a local copy with Loki's tables): health, the published site by its free address and own domain, the preview (noindex), names nobody holds (404), Caddy's ask, and a form refused for a missing field (nothing is sent):

node scripts/smoke.mjs --site <slug> [--domain d] [--preview <site id>] \
  [--absent <slug>] [--form <slug>:<page>] [--engine http://127.0.0.1:4042]

Without --engine it asks https://<host> like a visitor.

S
Description
No description provided
Readme MIT
424 KiB
0 Stars 2 Watchers 0 Forks
Languages
TypeScript 82.2%
JavaScript 15.8%
CSS 2%