-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
feat: move to compress
and decompress
route options and typescript improvements
#199
Conversation
onUnsupportedRequestEncoding?: (encoding: string, request: FastifyRequest, reply: FastifyReply) => Error | undefined | null; | ||
requestEncodings?: EncodingToken[]; | ||
threshold?: number; | ||
zlib?: unknown; |
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.
Previously it was defined as NodeModule
, but I don't think it's ok, example :
const zlib = require('zlib')
app.register(fastifyCompress, {
zlib: zlib // this will trigger a typescript argument error if set to NodeModule
})
unknown
is more suited here I think. WDYT ?
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 avoid the breaking change? Just document the new way and copy the old option into the new one.
@mcollina > Yes code wise I think I can avoid the breaking change by applying your suggestion and by throwing a deprecation hint warning with typescript (Typescript wise it should be doable, I will try to research a way of tweaking routes config typescript types). 'use strict'
const app: FastifyInstance = fastify()
app.register(require('fastify-compress'), { global: false })
app.get('/', {
compress: {
zlib: {
createGzip: () => createCustomGzipOne() // This one will be the final chosen value. Is it OK ?
}
},
config: {
compress: {
zlib: {
createGzip: () => createCustomGzipTwo()
}
}
}
}, (req, reply) => {
// ...
}) |
The outer one takes precendence. |
@mcollina > Oups sorry I made a mistake in my example, I intended to give precedence to the new |
compress
and decompress
route options and typescript improvementscompress
and decompress
route options and typescript improvements
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, this is ok
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
Hello.
Following #198 proposal, this PR aims to :
compress
anddecompress
route shorthand configuration propertiesNote: some of those changes are breaking changes and will require a major bump.Checklist
npm run test
andnpm run benchmark
and/or benchmarksare includedand the Code of conduct