Skip to content
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

Feature\#89 - Per route options for compression #92

Merged
merged 9 commits into from
Dec 13, 2019

Conversation

Svjard
Copy link
Contributor

@Svjard Svjard commented Dec 7, 2019

Checklist

  • run npm run test and npm run benchmark
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message and code follows Code of conduct

Expanded the test suite to handle per route tests.
Updated to decorate properly with different routes.
@Svjard
Copy link
Contributor Author

Svjard commented Dec 7, 2019

Feature for #89.

Took a first pass at this welcome feedback on it. In particular:

  1. Removed the decorate call to instead have compress() flow from the start of the request on the reply. Because each route can be configured differently was hard to determine the best approach from the previous approach.
  2. Better tests for per route, have a minimal set but open to writing more if you have some good ones I can add.
  3. The package.json is pointing to master, I know this needs to change but waiting for the next Fastify publish.

Copy link
Member

@Eomm Eomm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

package.json Outdated Show resolved Hide resolved
test/test-routes.js Show resolved Hide resolved
package.json Outdated
@@ -23,7 +24,7 @@
"@types/node": "^12.0.8",
"@typescript-eslint/parser": "^2.0.0",
"eslint-plugin-typescript": "^0.14.0",
"fastify": "^2.0.0",
"fastify": "fastify/fastify#master",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be released in 2.11 👍

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks

index.js Show resolved Hide resolved
index.js Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
index.js Show resolved Hide resolved
index.js Show resolved Hide resolved
index.js Show resolved Hide resolved
@mcollina
Copy link
Member

https://github.com/fastify/fastify-compress/pull/92/files#diff-168726dbe96b3ce427e7fedce31bb0bcR314

Can you bump this to fastify v2.11? That's the one you'll need for this fix.

@mcollina
Copy link
Member

(this will be a semver-major change).

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work! Don't forget to change

fastify: '>=1.3.0',
.

index.js Outdated
}

next()
function onRequest (req, reply, next) {
reply.compress = compress(params)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that params will not change, can you cache the output of compress(params) outside of the onRequest hook?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Svjard Svjard requested a review from mcollina December 13, 2019 20:18
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants