FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

new way to pass the configuration to the encodings by bjohansebas · Pull Request #232 · expressjs/compression · GitHub

new way to pass the configuration to the encodings - #232

Open
bjohansebas wants to merge 9 commits into
v2from
new-options-format
Open

bjohansebas wants to merge 9 commits into
v2from
new-options-format

Conversation

bjohansebas commented Apr 16, 2025
edited
Loading

Copy link
Copy Markdown
Member

Problem

In the current design of how the properties are passed, the options for deflate and gzip are the same. This means that if you want to have different configurations for these two encodings, you won’t be able to. Additionally, you can’t disable these encodings, which in cases like #25, might require disabling a specific encoding.

Solution

The solution is to handle the configurations separately, where each encoding has its own configuration, and also to provide the ability to disable an encoding by passing false.

// OLD
compression({ level: -1, chunkSize: 7000 }) // It applies to both deflate and gzip. 
// Brotli has its own separate configuration.

// NEW
compression({ encodings: { gzip: { level: -1, chunkSize: 7000}  }) // It only applies to gzip.
compression({ encodings: { gzip: false   }) // Disable gzip.

Suggestions about this new API are welcome.

Closes #220
Closes #25
Closes #27

This comment was marked as resolved.

Signed-off-by: Sebastian Beltran <bjohansebas@gmail.com>
Comment thread index.js Outdated
bjohansebas added this to the 2.0 milestone Apr 16, 2025
Signed-off-by: Sebastian Beltran <bjohansebas@gmail.com>
…ptions

Signed-off-by: Sebastian Beltran <bjohansebas@gmail.com>
Signed-off-by: Sebastian Beltran <bjohansebas@gmail.com>
bjohansebas requested a review from Copilot May 3, 2025 23:30

This comment was marked as resolved.

Signed-off-by: Sebastian Beltran <bjohansebas@gmail.com>
Signed-off-by: Sebastian Beltran <bjohansebas@gmail.com>
bjohansebas requested a review from Copilot May 3, 2025 23:36

This comment was marked as resolved.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL