Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <v2.0.0)* |
| decorateRequest | Decorates the fastify request with the lambda Event and Context `request.awsLambda.event` `request.awsLambda.context` | `true` |
| decorationPropertyName | The default property name for request decoration | `awsLambda` |
Expand Down
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Context } from "aws-lambda";
import { FastifyInstance, FastifyReply } from "fastify";
import { FastifyInstance, LightMyRequestResponse } from "fastify";

export interface LambdaFastifyOptions {
binaryMimeTypes?: string[];
callbackWaitsForEmptyEventLoop?: boolean;
serializeLambdaArguments?: boolean;
decorateRequest?: boolean;
decorationPropertyName?: string;
enforceBase64?: (reply: FastifyReply) => boolean;
enforceBase64?: (response: LightMyRequestResponse) => boolean;
}

export interface LambdaResponse {
Expand Down
7 changes: 5 additions & 2 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fastify from "fastify";
import fastify, {LightMyRequestResponse} from "fastify";
import awsLambdaFastify, {
PromiseHandler,
CallbackHandler,
Expand Down Expand Up @@ -70,7 +70,10 @@ expectAssignable<LambdaFastifyOptions>({
serializeLambdaArguments: false,
decorateRequest: true,
decorationPropertyName: "myAWSstuff",
enforceBase64: (reply) => false,
enforceBase64: (response) => {
expectType<LightMyRequestResponse>(response);
return false;
},
});

expectError(awsLambdaFastify());
Expand Down
2 changes: 1 addition & 1 deletion test/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down