MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / buildApp

Function buildApp

packages/server/test/error-handler.test.ts:25–41  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23import { resolveRequestId } from '../src/request-id';
24
25function 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
43describe('error handler — envelope wrapping', () => {
44 it('returns HTTP 200 with code 50001 envelope on unhandled exception', async () => {

Callers 1

Calls 5

resolveRequestIdFunction · 0.90
installErrorHandlerFunction · 0.90
okEnvelopeFunction · 0.90
getMethod · 0.65
sendMethod · 0.65

Tested by

no test coverage detected