diff --git a/src/lib/builder.ts b/src/lib/builder.ts index afb693e2..8d192cab 100644 --- a/src/lib/builder.ts +++ b/src/lib/builder.ts @@ -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 } diff --git a/test/builder.js b/test/builder.js index 187d1387..9cc01fe7 100644 --- a/test/builder.js +++ b/test/builder.js @@ -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, @@ -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) => {