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
+7
View File
@@ -329,6 +329,13 @@ jobs:
# scripts/service-http-baseline.json. A service throws a DomainError.
run: cd server && npm run lint:service-http
- name: Route handlers without a response contract may only shrink
# Counts the handlers under src/nest/ without @ResponseContract (or a
# response-contract-exempt comment) per file against
# scripts/response-contract-baseline.json. A covered handler's
# responses are parsed against its @trek/shared schema in every test.
run: cd server && npm run lint:response-contracts
- name: Open request schemas may only shrink
# Needs the shared build above. Counts open shapes (records of
# unknown, passthrough, any) in shared's request schemas.