Commit Graph
3 Commits
Author SHA1 Message Date
Fredrik JohanssonandClaude Sonnet 5 0d825b4458 Split server.mjs into modules: db, views, routes
server.mjs mixed SQL schema, HTML-rendering functions, and route
handling in one 476-line file. Split by concern:

- src/db.mjs — schema + migrations (openDb())
- src/views.mjs — pure render functions: layout, incidentForm,
  publicMarkdown/Incident/Detail, no db or network access
- src/style.mjs — the stylesheet, now genuinely shared instead of
  duplicated (receipts.mjs's /events page had its own near-copy,
  which is exactly what let their <nav> definitions drift out of
  sync a few commits ago)
- src/http-utils.mjs — form()/redirect(), used by more than one route
- src/routes/incidents.mjs — the private notebook + Git inbox +
  publish/unpublish, auth-gated once at the top instead of per-route
- src/routes/public-failures.mjs — the read-only /api/v1/public/failures*
  projection

server.mjs is now 79 lines of composition: open the db, build each
route module, wire the dispatch order, listen.

Also dropped the old POST /api/receipts endpoint and its `receipts`
table — dead since the v1 events API replaced it, already flagged as
"scheduled for removal" in the README.

Verified behavior is unchanged, not just "looks the same": full route
smoke test (401/200/404 in the right places, incident create→publish→
public-projection round trip, receipt ingestion), tests pass, and
before/after screenshots of every page are pixel-identical.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-21 05:27:27 +02:00
Fredrik JohanssonandClaude Sonnet 5 4b7b5a42d3 Reformat src/*.mjs with Prettier; add format/format:check scripts
Every route handler was written as one dense semicolon-chained line
(server.mjs's main handler was over 2000 characters wide) — real
width, not a VSCode wrapping artifact. Ran Prettier to break statement
structure into properly indented multi-line code; left template
literal string contents untouched since Prettier doesn't reformat
inside those, so the large HTML-generating return strings are still
single long lines by nature, just no longer compounded by unformatted
surrounding JS. Verified: tests pass, node --check passes, and the
app renders identically before/after (screenshotted the diff).

No devDependency added — npx prettier@3.9.5 pinned in the new scripts
keeps the zero-runtime-dependency pledge intact; formatting is a dev-
time concern only.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-21 05:17:30 +02:00
Fredrik Johansson 97ac266cd0 Build private incident notebook MVP 2026-07-20 20:25:17 +02:00