-
-
Couldn't load subscription status.
- Fork 50
feat: allow enabling and disabling compression and decompression separately #362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: allow enabling and disabling compression and decompression separately #362
Conversation
c95c62f to
efba7ef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you run npm run lint:fix?
efba7ef to
b166462
Compare
Co-authored-by: Frazer Smith <[email protected]> Signed-off-by: Bart Riepe <[email protected]>
|
@Eomm Yeah, hadn't realized I didn't do so until I saw the PR complaining about it. Hopefully good now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enables separate control of compression and decompression functionality by introducing new configuration options globalCompression and globalDecompression. Previously, the single global option controlled both features together.
- Adds
globalCompressionandglobalDecompressionoptions that fall back to the existingglobaloption when not specified - Updates both compression and decompression parameter processing to respect the new separate flags
- Documents the new configuration options with usage examples
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| index.js | Modifies parameter processing logic to check new global flags before falling back to existing global option |
| README.md | Adds documentation and example for the new globalCompression/globalDecompression configuration |
| test/global-compress.test.js | Adds comprehensive test coverage for the new separate compression/decompression control functionality |
Comments suppressed due to low confidence (2)
test/global-compress.test.js:344
- The zlib module is used but not imported in this file. Add 'const zlib = require('zlib')' at the top of the file.
test('using gzip when `Accept-Encoding` request header is `gzip`', async (t) => {
test/global-compress.test.js:430
- The zlib module is used but not imported in this file. Add 'const zlib = require('zlib')' at the top of the file.
const payload = zlib.gunzipSync(response.rawPayload)
| // only decompress compressed incoming requests | ||
| { globalCompression: false } | ||
| ) |
Copilot
AI
Jul 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The example shows only disabling compression but the comment mentions 'only decompress'. Consider showing both options or clarifying that globalDecompression defaults to true.
| // only decompress compressed incoming requests | |
| { globalCompression: false } | |
| ) | |
| // Disable compression but keep decompression enabled (default behavior for globalDecompression is true) | |
| { globalCompression: false } | |
| ) | |
| // Disable decompression but keep compression enabled | |
| await fastify.register( | |
| import('@fastify/compress'), | |
| { globalDecompression: false } | |
| ) |
This splits out the keys for enabling decompression and compression. I basically wanted to use the library to decompress incoming requests only, but got free compression for my trouble (which caused the issue that I had in the other PR I submitted).
Checklist
npm run testandnpm run benchmarkand the Code of conduct