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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: move to compress and decompress route specific options, improved typescript types and tests, reorganize tests #198

Closed
6 tasks done
darkgl0w opened this issue Nov 26, 2021 · 1 comment 路 Fixed by #201

Comments

@darkgl0w
Copy link
Member

darkgl0w commented Nov 26, 2021

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

馃殌 Feature Proposal

Hello,

following the PR #196, I would like to work on a few things for this package that will help improve development experience:

  • Add compress and decompress route shorthand configuration properties
  • Improve typescript types and actually test those types
  • Update the documentation
  • Reorganize and/or rewrite tests (renaming files following xxx.test.js convention, making groups with sub-tests, ...)

Note: some of those changes are breaking changes and will require a major bump.

If you think my proposal is acceptable the first 3 points are covered by this PR #199.

Regards.

Motivation

  • It will follow the way over official packages define specific route options, it will be shorter ( 馃ぃ ) and more intuitive.
  • It will have complete typings and those types will actually be tested.

Example

Current way to configure specific route options:

'use strict'

const zlib = require('zlib')
const fastify = require('fastify')()

fastify.register(require('fastify-compress', { global: false })

fastify.get('/one', {
  config: {
    compress: { createGzip: () => zlib.createGzip() },
    decompress: { createGunzip: () => zlib.createGunzip() }
  }
}, (request, reply) => {
 // ...
})

fastify.route({
  method: 'GET',
  path: '/two',
  config: {
    compress: { createGzip: () => zlib.createGzip() },
    decompress: { createGunzip: () => zlib.createGunzip() }
  },
  handler: (request, reply) => {
   // ...
  }
})

New way to configure specific route options:

'use strict'

const zlib = require('zlib')
const fastify = require('fastify')()

fastify.register(require('fastify-compress', { global: false })

fastify.get('/one', {
  compress: { createGzip: () => zlib.createGzip() },
  decompress: { createGunzip: () => zlib.createGunzip() }
}, (request, reply) => {
 // ...
})

fastify.route({
  method: 'GET',
  path: '/two',
  compress: { createGzip: () => zlib.createGzip() },
  decompress: { createGunzip: () => zlib.createGunzip() },
  handler: (request, reply) => {
   // ...
  }
})
@darkgl0w
Copy link
Member Author

darkgl0w commented Nov 30, 2021

I have started to work on the last part of the proposal with a big overhaul on tests :
reorganize and/or rewrite tests (renaming files following xxx.test.js convention, making groups with sub-tests, ...).

I will submit a PR after the landing of #199

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 a pull request may close this issue.

1 participant