Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { HandlerContext, HandlerEvent } from '../function'
import { BuilderHandler, Handler, HandlerCallback } from '../function/handler'
import { Response, BuilderResponse } from '../function/response'

import { BUILDER_FUNCTIONS_FLAG, HTTP_STATUS_METHOD_NOT_ALLOWED, HTTP_STATUS_OK, METADATA_VERSION } from './consts'
import { BUILDER_FUNCTIONS_FLAG, HTTP_STATUS_METHOD_NOT_ALLOWED, METADATA_VERSION } from './consts'

const augmentResponse = (response: BuilderResponse) => {
if (!response || response.statusCode !== HTTP_STATUS_OK) {
if (!response) {
return response
}
const metadata = { version: METADATA_VERSION, builder_function: BUILDER_FUNCTIONS_FLAG, ttl: response.ttl ?? 0 }
Expand Down
4 changes: 2 additions & 2 deletions test/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test('Injects the metadata object into a synchronous handler', async (t) => {
t.deepEqual(response, { ...originalResponse, ...METADATA_OBJECT })
})

test('Does not inject the metadata object for non-200 responses', async (t) => {
test('Injects the metadata object for non-200 responses', async (t) => {
const originalResponse = {
body: ':thumbsdown:',
statusCode: 404,
Expand All @@ -55,7 +55,7 @@ test('Does not inject the metadata object for non-200 responses', async (t) => {
}
const response = await invokeLambda(builder(myHandler))

t.deepEqual(response, originalResponse)
t.deepEqual(response, { ...originalResponse, ...METADATA_OBJECT })
})

test('Returns a 405 error for requests using the POST method', async (t) => {
Expand Down