compression

View Source

Summary

Creates a middleware handler that automatically compresses responses based on the client's Accept-Encoding header, along with an additional Content-Type filter by default to only apply compression to appropriate media types.

Signature

function compression(options: CompressionOptions): Middleware;

Example

let router = createRouter({
  middleware: [compression()],
})

Params

options

Optional compression settings

Returns

A middleware handler that automatically compresses responses based on the client's Accept-Encoding header