@fastify/aws-lambda
Advanced tools
Comparing version 5.0.0 to 5.1.0
15
index.js
@@ -21,2 +21,3 @@ 'use strict' | ||
options.parseCommaSeparatedQueryParams = options.parseCommaSeparatedQueryParams !== undefined ? options.parseCommaSeparatedQueryParams : true | ||
options.payloadAsStream = options.payloadAsStream !== undefined ? options.payloadAsStream : false | ||
let currentAwsArguments = {} | ||
@@ -114,3 +115,3 @@ if (options.decorateRequest) { | ||
const prom = new Promise((resolve) => { | ||
app.inject({ method, url, query, payload, headers, remoteAddress }, (err, res) => { | ||
app.inject({ method, url, query, payload, headers, remoteAddress, payloadAsStream: options.payloadAsStream }, (err, res) => { | ||
currentAwsArguments = {} | ||
@@ -154,3 +155,2 @@ if (err) { | ||
statusCode: res.statusCode, | ||
body: isBase64Encoded ? res.rawPayload.toString('base64') : res.payload, | ||
headers: res.headers, | ||
@@ -162,3 +162,12 @@ isBase64Encoded | ||
if (multiValueHeaders && (!event.version || event.version === '1.0')) ret.multiValueHeaders = multiValueHeaders | ||
resolve(ret) | ||
if (!options.payloadAsStream) { | ||
ret.body = isBase64Encoded ? res.rawPayload.toString('base64') : res.payload | ||
return resolve(ret) | ||
} | ||
resolve({ | ||
meta: ret, | ||
stream: res.stream() | ||
}) | ||
}) | ||
@@ -165,0 +174,0 @@ }) |
@@ -29,3 +29,3 @@ { | ||
"license": "MIT", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"main": "index.js", | ||
@@ -37,3 +37,3 @@ "type": "commonjs", | ||
"test": "npm run test:unit && npm run test:typescript", | ||
"test:unit": "tap -J -R specy --no-coverage test/*test.js", | ||
"test:unit": "node scripts/unit.js", | ||
"test:typescript": "tsd", | ||
@@ -45,19 +45,21 @@ "performance": "npm run lint && node performanceTest/test", | ||
"devDependencies": { | ||
"@fastify/multipart": "^9.0.0", | ||
"@fastify/pre-commit": "^2.1.0", | ||
"@h4ad/serverless-adapter": "4.2.3", | ||
"@types/aws-lambda": "8.10.145", | ||
"@eslint/eslintrc": "3.2.0", | ||
"@eslint/js": "9.18.0", | ||
"@fastify/multipart": "^9.0.2", | ||
"@fastify/pre-commit": "^2.2.0", | ||
"@h4ad/serverless-adapter": "4.4.0", | ||
"@types/aws-lambda": "8.10.147", | ||
"aws-serverless-express": "^3.4.0", | ||
"aws-serverless-fastify": "^3.1.0", | ||
"benchmark": "^2.1.4", | ||
"eslint": "^8.56.0", | ||
"eslint": "^9.18.0", | ||
"eslint-config-standard": "^17.1.0", | ||
"eslint-plugin-import": "^2.29.1", | ||
"eslint-plugin-n": "^16.6.2", | ||
"eslint-plugin-promise": "^6.1.1", | ||
"eslint-plugin-import": "^2.31.0", | ||
"eslint-plugin-n": "^17.15.1", | ||
"eslint-plugin-promise": "^7.2.1", | ||
"eslint-plugin-standard": "^5.0.0", | ||
"fastify": "^5.0.0", | ||
"fast-glob": "^3.3.3", | ||
"fastify": "^5.2.1", | ||
"serverless-http": "^3.2.0", | ||
"tap": "^16.3.9", | ||
"tsd": "^0.31.0" | ||
"tsd": "^0.31.2" | ||
}, | ||
@@ -64,0 +66,0 @@ "publishConfig": { |
# Introduction | ||
![CI](https://github.com/fastify/aws-lambda-fastify/workflows/CI/badge.svg) | ||
[![CI](https://github.com/fastify/aws-lambda-fastify/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/fastify/aws-lambda-fastify/actions/workflows/ci.yml) | ||
[![NPM version](https://img.shields.io/npm/v/@fastify/aws-lambda.svg?style=flat)](https://www.npmjs.com/package/@fastify/aws-lambda) | ||
@@ -5,0 +5,0 @@ [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/) |
@@ -22,5 +22,5 @@ import { Context } from "aws-lambda"; | ||
* Affects the behavior of the querystring parser with commas while using [Payload Format Version 2.0](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html#http-api-develop-integrations-lambda.proxy-format) | ||
* | ||
* | ||
* e.g. when set to `true` (default) `?foo=qux,bar` => `{ foo: ['qux', 'bar'] }` | ||
* | ||
* | ||
* e.g. when set to `false` `?foo=qux,bar` => `{ foo: 'qux,bar' }` | ||
@@ -31,3 +31,3 @@ * @default true | ||
} | ||
export interface LambdaResponse { | ||
@@ -40,3 +40,3 @@ statusCode: number; | ||
} | ||
export type PromiseHandler<TEvent = any, TResult = LambdaResponse> = ( | ||
@@ -46,3 +46,3 @@ event: TEvent, | ||
) => Promise<TResult>; | ||
export type CallbackHandler<TEvent = any, TResult = LambdaResponse> = ( | ||
@@ -53,3 +53,3 @@ event: TEvent, | ||
) => void; | ||
export const awsLambdaFastify: AwsLambdaFastify | ||
@@ -56,0 +56,0 @@ export { awsLambdaFastify as default } |
Sorry, the diff of this file is not supported yet
26367
8
329
19