aws-lambda-fastify
Advanced tools
Comparing version 2.0.2 to 2.1.0
15
index.js
@@ -36,3 +36,16 @@ module.exports = (app, options) => { | ||
} | ||
const query = event.multiValueQueryStringParameters || event.queryStringParameters || {} | ||
const query = {} | ||
if (event.requestContext && event.requestContext.elb) { | ||
if (event.multiValueQueryStringParameters) { | ||
Object.keys(event.multiValueQueryStringParameters).forEach((q) => { | ||
query[decodeURIComponent(q)] = event.multiValueQueryStringParameters[q].map((val) => decodeURIComponent(val)) | ||
}) | ||
} else if (event.queryStringParameters) { | ||
Object.keys(event.queryStringParameters).forEach((q) => { | ||
query[decodeURIComponent(q)] = decodeURIComponent(event.queryStringParameters[q]) | ||
}) | ||
} | ||
} else { | ||
Object.assign(query, event.multiValueQueryStringParameters || event.queryStringParameters) | ||
} | ||
const headers = Object.assign({}, event.headers) | ||
@@ -39,0 +52,0 @@ if (event.multiValueHeaders) { |
@@ -29,3 +29,3 @@ { | ||
"license": "MIT", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"main": "index.js", | ||
@@ -43,13 +43,13 @@ "scripts": { | ||
"benchmark": "^2.1.4", | ||
"eslint": "^8.5.0", | ||
"eslint": "^8.7.0", | ||
"eslint-config-standard": "^16.0.3", | ||
"eslint-plugin-import": "^2.25.3", | ||
"eslint-plugin-import": "^2.25.4", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-promise": "^6.0.0", | ||
"eslint-plugin-standard": "^5.0.0", | ||
"fastify": "^3.25.0", | ||
"fastify": "^3.27.0", | ||
"serverless-http": "^2.7.0", | ||
"tap": "^15.1.5", | ||
"tsd": "^0.19.0" | ||
"tap": "^15.1.6", | ||
"tsd": "^0.19.1" | ||
} | ||
} |
@@ -83,2 +83,4 @@ # Introduction | ||
#### Lambda arguments | ||
The original lambda event and context are passed via Fastify request and can be used like this: | ||
@@ -106,3 +108,18 @@ | ||
#### Lower cold start latency | ||
Since [AWS Lambda now enables the use of ECMAScript (ES) modules](https://aws.amazon.com/blogs/compute/using-node-js-es-modules-and-top-level-await-in-aws-lambda/) in Node.js 14 runtimes, you could lower the cold start latency when used with [Provisioned Concurrency](https://aws.amazon.com/blogs/compute/new-for-aws-lambda-predictable-start-up-times-with-provisioned-concurrency/) thanks to the top-level await functionality. | ||
We can use this by calling the [`fastify.ready()`](https://www.fastify.io/docs/latest/Reference/Server/#ready) function outside of the Lambda handler function, like this: | ||
```js | ||
import awsLambdaFastify from 'aws-lambda-fastify' | ||
import app from './app.js' | ||
export const handler = awsLambdaFastify(app) | ||
await app.ready() // needs to be placed after awsLambdaFastify call because of the decoration: https://github.com/fastify/aws-lambda-fastify/blob/master/index.js#L9 | ||
``` | ||
*[Here](https://github.com/fastify/aws-lambda-fastify/issues/89) you can find the approriate issue discussing this feature.* | ||
## ⚡️Some basic performance metrics | ||
@@ -109,0 +126,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21008
207
159