Skip to content

Commit e345ec6

Browse files
Change response shape
1 parent 3b562ce commit e345ec6

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

infrastructure/terraform/components/api/resources/spec.tmpl.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"operationId": "getStatusId",
2929
"responses": {
3030
"200": {
31-
"description": "Empty body"
31+
"description": "OK"
3232
},
3333
"500": {
3434
"description": "Server error"

lambdas/api-handler/src/handlers/__tests__/get_status.test.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('API Lambda handler', () => {
1919

2020
expect(result).toEqual({
2121
statusCode: 200,
22-
body: '{}',
22+
body: JSON.stringify({ code: 200 }, null, 2)
2323
});
2424
});
2525

@@ -34,9 +34,10 @@ describe('API Lambda handler', () => {
3434
const getLetterDataHandler = createGetStatusHandler(mockedDeps);
3535
const result = await getLetterDataHandler(event, mockDeep<Context>(), jest.fn());
3636

37-
expect(result).toEqual(expect.objectContaining({
38-
statusCode: 500
39-
}));
37+
expect(result).toEqual({
38+
statusCode: 500,
39+
body: JSON.stringify({ code: 500 }, null, 2)
40+
});
4041
});
4142

4243

@@ -51,9 +52,10 @@ describe('API Lambda handler', () => {
5152
const getLetterDataHandler = createGetStatusHandler(mockedDeps);
5253
const result = await getLetterDataHandler(event, mockDeep<Context>(), jest.fn());
5354

54-
expect(result).toEqual(expect.objectContaining({
55-
statusCode: 500
56-
}));
55+
expect(result).toEqual({
56+
statusCode: 500,
57+
body: JSON.stringify({ code: 500 }, null, 2)
58+
});
5759
});
5860

5961

lambdas/api-handler/src/handlers/get-status.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ export function createGetStatusHandler(deps: Deps): APIGatewayProxyHandler {
1717

1818
return {
1919
statusCode: 200,
20-
body: '{}'
20+
body: JSON.stringify({ code: 200 }, null, 2)
2121
};
2222
} catch (error) {
23-
return mapErrorToResponse(error, undefined, deps.logger);
23+
deps.logger.error({ err: error }, 'Status endpoint error, services not available');
24+
return {
25+
statusCode: 500,
26+
body: JSON.stringify({ code: 500 }, null, 2)
27+
};
2428
}
2529
}
2630
}

0 commit comments

Comments
 (0)