Skip to content
This repository has been archived by the owner on Sep 22, 2019. It is now read-only.

SerayaEryn/fastify-compression

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastify-compression

DEPRECATED Please use fastify-compress instead.

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