feat(server): @ResponseContract checks a handler's responses against its shared schema in tests

The decorator records the @trek/shared response schema a route answers
with. Under NODE_ENV=test it adds an interceptor that parses every response
and fails the request with a logged 500 naming the handler and the issues,
so the e2e and integration suites catch a response that drifted from its
contract; in production nothing is added to the request path and the body
is never rewritten. lint:response-contracts holds the handlers still without
one to a per-file baseline that only shrinks, and runs in server-quality.
This commit is contained in:
Maurice
2026-10-10 15:53:51 +02:00
parent 81ec7dd28d
commit 87071bf738
10 changed files with 700 additions and 4 deletions
+1
View File
@@ -26,6 +26,7 @@
"lint:query-api": "node scripts/query-api-ratchet.mjs",
"lint:mcp-zod": "node scripts/mcp-inline-zod.mjs",
"lint:service-http": "node scripts/service-http-ratchet.mjs",
"lint:response-contracts": "node scripts/response-contract-ratchet.mjs",
"contracts:dto-open": "node scripts/dto-open-shapes.mjs",
"gen:plugin-facts": "node --import tsx scripts/gen-plugin-facts.ts",
"check:plugin-facts": "node --import tsx scripts/gen-plugin-facts.ts --check",