fastify-compression

1.3.0 • Public • Published

fastify-compression

Greenkeeper badge Build Status Coverage Status NPM version JavaScript Style Guide

A compression plugin for Fastify. Supports gzip, deflate and brotli.

Usage

const fastify = require('fastify');
const fastifyCompression = require('fastify-compression');

const app = fastify();
app.register(fastifyCompression, {threshold: 2048});

API

compression(fastify, options, next)

Compresses the payload with gzip, brotli or deflate if the payload length is above the threshold and a Accept-Encoding header is send with the request. In case of an asterisk * in the Accept-Encoding header gzip will be chosen.

options

threshold (optional)

A number that specifies the threshold used to determine if compression should be applied. Defaults to 1024.

brotli

To enable Brotli compression pass the iltorb module with the brotli option.
Note: Since version 11.7.0 brotli is being supported by Node.js itself. Therefore the brotli option is no longer necessary.

License

MIT

Dependents (0)

Package Sidebar

Install

npm i fastify-compression

Weekly Downloads

12

Version

1.3.0

License

MIT

Unpacked Size

22.1 kB

Total Files

9

Last publish

Collaborators

  • serayaeryn