@fastify/compress 6.5.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/index.js +6 -1
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![NPM version](https://img.shields.io/npm/v/@fastify/compress.svg?style=flat)](https://www.npmjs.com/package/@fastify/compress)
5
5
  [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
6
6
 
7
- Adds compression utils to [the Fastify `reply` object](https://www.fastify.io/docs/latest/Reference/Reply/#reply) and a hook to decompress requests payloads.
7
+ Adds compression utils to [the Fastify `reply` object](https://fastify.dev/docs/latest/Reference/Reply/#reply) and a hook to decompress requests payloads.
8
8
  Supports `gzip`, `deflate`, and `brotli`.
9
9
 
10
10
  > **Important note:** since `@fastify/compress` version 4.x payloads that are compressed using the `zip` algorithm are not automatically uncompressed anymore. `@fastify/compress` main feature is to provide response compression mechanism to your server, however the `zip` format does not appear in the [IANA maintained Table of Content Encodings](https://www.iana.org/assignments/http-parameters/http-parameters.xml#content-coding) and thus such behavior was out of the scope of this plugin.
@@ -169,7 +169,7 @@ You can tune compression by setting the `brotliOptions` and `zlibOptions` proper
169
169
  brotliOptions: {
170
170
  params: {
171
171
  [zlib.constants.BROTLI_PARAM_MODE]: zlib.constants.BROTLI_MODE_TEXT, // useful for APIs that primarily return text
172
- [zlib.constants.BROTLI_PARAM_QUALITY]: 4, // default is 11, max is 11, min is 0
172
+ [zlib.constants.BROTLI_PARAM_QUALITY]: 4, // default is 4, max is 11, min is 0
173
173
  },
174
174
  },
175
175
  zlibOptions: {
package/index.js CHANGED
@@ -117,7 +117,12 @@ function processCompressParams (opts) {
117
117
  }
118
118
 
119
119
  const params = {
120
- global: (typeof opts.global === 'boolean') ? opts.global : true
120
+ global: (typeof opts.global === 'boolean') ? opts.global : true,
121
+ /**
122
+ * Default of 4 as 11 has a heavy impact on performance.
123
+ * @see {@link https://blog.cloudflare.com/this-is-brotli-from-origin#testing}
124
+ */
125
+ brotliOptions: { [zlib.constants.BROTLI_PARAM_QUALITY]: 4, ...opts.brotliOptions }
121
126
  }
122
127
 
123
128
  params.removeContentLengthHeader = typeof opts.removeContentLengthHeader === 'boolean' ? opts.removeContentLengthHeader : true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastify/compress",
3
- "version": "6.5.0",
3
+ "version": "7.0.0",
4
4
  "description": "Fastify compression utils",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
@@ -25,7 +25,7 @@
25
25
  "jsonstream": "^1.0.3",
26
26
  "standard": "^17.1.0",
27
27
  "tap": "^16.3.7",
28
- "tsd": "^0.29.0",
28
+ "tsd": "^0.30.0",
29
29
  "typescript": "^5.1.6"
30
30
  },
31
31
  "scripts": {