mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 05:26:47 +00:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user