1.3.0 • Published 7 years ago
fastify-compression v1.3.0
fastify-compression
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.