()
| 23 | import { resolveRequestId } from '../src/request-id'; |
| 24 | |
| 25 | function buildApp() { |
| 26 | const app = Fastify({ |
| 27 | loggerInstance: pino({ level: 'silent' }), |
| 28 | disableRequestLogging: true, |
| 29 | genReqId: (req) => resolveRequestId(req.headers as Record<string, string | string[] | undefined>), |
| 30 | }); |
| 31 | installErrorHandler(app); |
| 32 | app.get('/api/v1/healthz', async (req, reply) => reply.send(okEnvelope({ ok: true }, req.id))); |
| 33 | app.get('/boom', async () => { |
| 34 | throw new Error('oops something broke'); |
| 35 | }); |
| 36 | app.get('/boom-empty', async () => { |
| 37 | const err = new Error(''); |
| 38 | throw err; |
| 39 | }); |
| 40 | return app; |
| 41 | } |
| 42 | |
| 43 | describe('error handler — envelope wrapping', () => { |
| 44 | it('returns HTTP 200 with code 50001 envelope on unhandled exception', async () => { |
no test coverage detected