Skip to content

Commit

Permalink
fix: don't set code 500 in status endpoint responses
Browse files Browse the repository at this point in the history
  • Loading branch information
sshelomentsev committed Mar 29, 2024
1 parent bb8684f commit b4a4d04
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 1 addition & 3 deletions mgmt-lambda/handlers/statusHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ export async function handleStatus(
cloudFrontDistribution: cloudFrontDistributionInformation,
}

const statusCode = lambdaFunctionInformation && cloudFrontDistributionInformation ? 200 : 500

return {
statusCode: statusCode,
statusCode: 200,
body: JSON.stringify(result),
headers: {
'content-type': 'application/json',
Expand Down
6 changes: 3 additions & 3 deletions mgmt-lambda/test/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ describe('Basic test', () => {
const event = generateStatusRequest(correctToken, 'GET', '///status')

const result = await handler(event)
expect(result.statusCode).toBe(500)
expect(result.statusCode).toBe(200)
})

test('endpoint with trailing slashes', async () => {
Expand All @@ -377,7 +377,7 @@ describe('Basic test', () => {
const event = generateStatusRequest(correctToken, 'GET', 'status/')

const result = await handler(event)
expect(result.statusCode).toBe(500)
expect(result.statusCode).toBe(200)
})

test('endpoint with leading and trailing slashes', async () => {
Expand All @@ -388,7 +388,7 @@ describe('Basic test', () => {
const event = generateStatusRequest(correctToken, 'GET', '//status/')

const result = await handler(event)
expect(result.statusCode).toBe(500)
expect(result.statusCode).toBe(200)
})

test('status endpoint with additional path', async () => {
Expand Down
2 changes: 1 addition & 1 deletion mgmt-lambda/test/handlers/handleStatus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,6 @@ describe('Handle mgmt-status', () => {
.rejects()

const status = await handleStatus(lambdaClient, cloudFrontClient, options)
expect(status.statusCode).toBe(500)
expect(status.statusCode).toBe(200)
})
})

0 comments on commit b4a4d04

Please sign in to comment.