Skip to content

new way to pass the configuration to the encodings #232

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

Open
wants to merge 9 commits into
base: v2
Choose a base branch
from

Conversation

bjohansebas
Copy link
Member

@bjohansebas bjohansebas commented Apr 16, 2025

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

Copilot

This comment was marked as resolved.

Signed-off-by: Sebastian Beltran <[email protected]>
@bjohansebas bjohansebas added this to the 2.0 milestone Apr 16, 2025
@bjohansebas bjohansebas requested a review from Copilot May 3, 2025 23:30
Copilot

This comment was marked as resolved.

Signed-off-by: Sebastian Beltran <[email protected]>
@bjohansebas bjohansebas requested a review from Copilot May 3, 2025 23:36
Copilot

This comment was marked as resolved.

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.

1 participant