0

I was able to find a way to normalize the request and response in a fastify onrequest hook, so that middleware written for express, like swagger-stats, can be used with fastify.

I was wondering if there would be any interest in me adding this as an option to the FastifyAdapter, so that others can benefit from it? The thought is if this option is turned on, then in the constructor the onrequest hook will be added to the fastify instance.

Kim Kern
  • 54,283
  • 17
  • 197
  • 195
  • 3
    Hi Eric, welcome to Stackoverflow! :-) Your request is better suited as an issue and/or pull request on the github repo, https://github.com/nestjs/nest/issues/new. I'm sure your contribution will be welcomed. See also https://stackoverflow.com/help/on-topic – Kim Kern Mar 09 '19 at 22:41
  • 1
    Thanks for the feedback. After consideration I will make a new **fastify** **plugin**, and publish it, so that the community can choose to use it or not. – Eric Glass Mar 10 '19 at 14:29

1 Answers1

0

The OP actually published the desired behavior as a fastify plugin.

You can install it via npm:

npm install --save fastify-normalize-request-reply

and then register it as a plugin with:

fastify.register(require('fastify-normalize-request-reply'));
Kim Kern
  • 54,283
  • 17
  • 197
  • 195