feat: log unhandled errors and pretty dev output (WealthLedger/backend#120) #126

Merged
codex-bot merged 5 commits from chore/121-linear-ci into develop 2026-10-24 15:06:34 +03:00
Showing only changes of commit 5cf0efd813 - Show all commits
+16 -13
View File
@@ -32,6 +32,7 @@ describe('Authentication (e2e)', () => {
pinoHttp: { pinoHttp: {
...loggingOptions(config), ...loggingOptions(config),
level: 'info', level: 'info',
transport: undefined,
stream: { write: (line: string) => logs.push(JSON.parse(line) as Record<string, unknown>) }, stream: { write: (line: string) => logs.push(JSON.parse(line) as Record<string, unknown>) },
}, },
assignResponse: true, assignResponse: true,
@@ -568,12 +569,21 @@ describe('Authentication (e2e)', () => {
expect(body).toEqual({ status: 500, code: 'INTERNAL_SERVER_ERROR' }), expect(body).toEqual({ status: 500, code: 'INTERNAL_SERVER_ERROR' }),
); );
const related = logs.filter((entry) => expect(logs).toEqual(
entry.requestId === response.headers['x-request-id'] || entry.clientRequestId === clientRequestId, expect.arrayContaining([
expect.objectContaining({
method: 'POST',
route: '/api/v1/auth/login',
status: 500,
code: 'INTERNAL_SERVER_ERROR',
level: 50,
message: 'http.request.completed',
}),
]),
); );
expect(related).toEqual([ expect(logs).toEqual(
expect.arrayContaining([
expect.objectContaining({ expect.objectContaining({
requestId: response.headers['x-request-id'],
clientRequestId, clientRequestId,
code: 'INTERNAL_SERVER_ERROR', code: 'INTERNAL_SERVER_ERROR',
level: 50, level: 50,
@@ -581,15 +591,8 @@ describe('Authentication (e2e)', () => {
errorName: 'Error', errorName: 'Error',
errorStack: expect.stringContaining(' at ') as unknown, errorStack: expect.stringContaining(' at ') as unknown,
}), }),
expect.objectContaining({ ]),
requestId: response.headers['x-request-id'], );
clientRequestId,
status: 500,
code: 'INTERNAL_SERVER_ERROR',
level: 50,
message: 'http.request.completed',
}),
]);
expect(JSON.stringify(logs)).not.toContain( expect(JSON.stringify(logs)).not.toContain(
'SYNTHETIC_AUDIT_SECRET', 'SYNTHETIC_AUDIT_SECRET',
); );