New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@fastify/aws-lambda

Package Overview
Dependencies
Maintainers
19
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fastify/aws-lambda - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

3

index.d.ts
import { Context } from "aws-lambda";
import { FastifyInstance } from "fastify";
import { FastifyInstance, FastifyReply } from "fastify";

@@ -10,2 +10,3 @@ export interface LambdaFastifyOptions {

decorationPropertyName?: string;
enforceBase64?: (reply: FastifyReply) => boolean;
}

@@ -12,0 +13,0 @@

@@ -0,1 +1,11 @@

const isCompressedDefault = (res) => {
const contentEncoding = res.headers['content-encoding'] || res.headers['Content-Encoding']
return contentEncoding && contentEncoding !== 'identity'
}
const customBinaryCheck = (options, res) => {
const enforceBase64 = typeof options.enforceBase64 === 'function' ? options.enforceBase64 : isCompressedDefault
return enforceBase64(res) === true
}
module.exports = (app, options) => {

@@ -113,3 +123,3 @@ options = options || {}

const contentType = (res.headers['content-type'] || res.headers['Content-Type'] || '').split(';')[0]
const isBase64Encoded = options.binaryMimeTypes.indexOf(contentType) > -1
const isBase64Encoded = options.binaryMimeTypes.indexOf(contentType) > -1 || customBinaryCheck(options, res)

@@ -116,0 +126,0 @@ const ret = {

@@ -67,4 +67,12 @@ import fastify from "fastify";

});
expectAssignable<LambdaFastifyOptions>({
binaryMimeTypes: ["foo", "bar"],
callbackWaitsForEmptyEventLoop: true,
serializeLambdaArguments: false,
decorateRequest: true,
decorationPropertyName: "myAWSstuff",
enforceBase64: (reply) => false,
});
expectError(awsLambdaFastify());
expectError(awsLambdaFastify(app, { neh: "definition" }));

@@ -29,3 +29,3 @@ {

"license": "MIT",
"version": "3.0.0",
"version": "3.1.0",
"main": "index.js",

@@ -39,3 +39,3 @@ "scripts": {

"devDependencies": {
"@types/aws-lambda": "8.10.97",
"@types/aws-lambda": "8.10.101",
"aws-lambda": "^1.0.7",

@@ -45,6 +45,6 @@ "aws-serverless-express": "^3.4.0",

"benchmark": "^2.1.4",
"eslint": "^8.16.0",
"eslint": "^8.17.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.2.0",
"eslint-plugin-n": "^15.2.1",
"eslint-plugin-promise": "^6.0.0",

@@ -55,3 +55,3 @@ "eslint-plugin-standard": "^5.0.0",

"tap": "^16.2.0",
"tsd": "^0.20.0"
"tsd": "^0.22.0"
},

@@ -58,0 +58,0 @@ "overrides": {

# Introduction
![CI](https://github.com/fastify/aws-lambda-fastify/workflows/CI/badge.svg)
[![NPM version](https://img.shields.io/npm/v/aws-lambda-fastify.svg?style=flat)](https://www.npmjs.com/package/aws-lambda-fastify)
[![NPM version](https://img.shields.io/npm/v/@fastify/aws-lambda.svg?style=flat)](https://www.npmjs.com/package/@fastify/aws-lambda)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)

@@ -16,3 +16,3 @@

```bash
$ npm install aws-lambda-fastify
$ npm i @fastify/aws-lambda
```

@@ -22,3 +22,3 @@

**aws-lambda-fastify** can take options by passing them with : `awsLambdaFastify(app, options)`
**@fastify/aws-lambda** can take options by passing them with : `awsLambdaFastify(app, options)`

@@ -28,2 +28,3 @@ | 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` |
| 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)* |

@@ -39,3 +40,3 @@ | decorateRequest | Decorates the fastify request with the lambda Event and Context `request.awsLambda.event` `request.awsLambda.context` | `true` |

```js
const awsLambdaFastify = require('aws-lambda-fastify')
const awsLambdaFastify = require('@fastify/aws-lambda')
const app = require('./app')

@@ -117,3 +118,3 @@

```js
import awsLambdaFastify from 'aws-lambda-fastify'
import awsLambdaFastify from '@fastify/aws-lambda'
import app from './app.js'

@@ -129,7 +130,7 @@ export const handler = awsLambdaFastify(app)

**aws-lambda-fastify (decorateRequest : false)** x **56,892 ops/sec** ±3.73% (79 runs sampled)
**@fastify/aws-lambda (decorateRequest : false)** x **56,892 ops/sec** ±3.73% (79 runs sampled)
**aws-lambda-fastify** x **56,571 ops/sec** ±3.52% (82 runs sampled)
**@fastify/aws-lambda** x **56,571 ops/sec** ±3.52% (82 runs sampled)
**aws-lambda-fastify (serializeLambdaArguments : true)** x **56,499 ops/sec** ±3.56% (76 runs sampled)
**@fastify/aws-lambda (serializeLambdaArguments : true)** x **56,499 ops/sec** ±3.56% (76 runs sampled)

@@ -142,3 +143,3 @@ **[serverless-http](https://github.com/dougmoscrop/serverless-http)** x **45,867 ops/sec** ±4.42% (83 runs sampled)

Fastest is **aws-lambda-fastify (decorateRequest : false), aws-lambda-fastify**
Fastest is **@fastify/aws-lambda (decorateRequest : false), @fastify/aws-lambda**

@@ -156,7 +157,7 @@ #### ⚠️Considerations

<a href="https://locize.com" target="_blank" rel="nofollow">
<img style="max-height: 80px;" src="https://raw.githubusercontent.com/fastify/aws-lambda-fastify/master/images/logos/locize.png" alt="locize is using aws-lambda-fastify"/>
<img style="max-height: 80px;" src="https://raw.githubusercontent.com/fastify/aws-lambda-fastify/master/images/logos/locize.png" alt="locize is using @fastify/aws-lambda"/>
</a>
<br />
<a href="https://localistars.com" target="_blank" rel="nofollow">
<img style="max-height: 80px;" src="https://raw.githubusercontent.com/fastify/aws-lambda-fastify/master/images/logos/localistars.png" alt="localistars is using aws-lambda-fastify"/>
<img style="max-height: 80px;" src="https://raw.githubusercontent.com/fastify/aws-lambda-fastify/master/images/logos/localistars.png" alt="localistars is using @fastify/aws-lambda"/>
</a>

@@ -166,2 +167,2 @@

<small>The logos displayed in this page are property of the respective organisations and they are
not distributed under the same license as aws-lambda-fastify (MIT).</small>
not distributed under the same license as @fastify/aws-lambda (MIT).</small>

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc