diff --git a/README.md b/README.md index dfb21ec..7a8b0ea 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ $ npm i @fastify/aws-lambda | property | description | default value | | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------ | ------------- | | binaryMimeTypes | Array of binary MimeTypes to handle | `[]` | -| enforceBase64 | Function that receives the reply and returns a boolean indicating if the response content is binary or not and should be base64-encoded | `undefined` | +| enforceBase64 | Function that receives the response and returns a boolean indicating if the response content is binary or not and should be base64-encoded | `undefined` | | serializeLambdaArguments | Activate the serialization of lambda Event and Context in http header `x-apigateway-event` `x-apigateway-context` | `false` *(was `true` for boolean; + enforceBase64?: (response: LightMyRequestResponse) => boolean; } export interface LambdaResponse { diff --git a/index.test-d.ts b/index.test-d.ts index 4926e6b..f70bc61 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,4 +1,4 @@ -import fastify from "fastify"; +import fastify, {LightMyRequestResponse} from "fastify"; import awsLambdaFastify, { PromiseHandler, CallbackHandler, @@ -70,7 +70,10 @@ expectAssignable({ serializeLambdaArguments: false, decorateRequest: true, decorationPropertyName: "myAWSstuff", - enforceBase64: (reply) => false, + enforceBase64: (response) => { + expectType(response); + return false; + }, }); expectError(awsLambdaFastify()); diff --git a/test/basic.test.js b/test/basic.test.js index 82d55e5..ec4d402 100644 --- a/test/basic.test.js +++ b/test/basic.test.js @@ -138,7 +138,7 @@ test('GET with custom binary check response', async (t) => { const proxy = awsLambdaFastify(app, { binaryMimeTypes: [], serializeLambdaArguments: true, - enforceBase64: (reply) => reply.headers['x-base64-encoded'] === '1' + enforceBase64: (response) => response.headers['x-base64-encoded'] === '1' }) const ret = await proxy({ httpMethod: 'GET',