Eomm / fastify-raw-body

Request raw body
MIT License
44 stars 10 forks source link

Possible to support Fastify v2? #3

Closed mikemaccana closed 4 years ago

mikemaccana commented 4 years ago

🚀 Feature Proposal

Currently V2 of Fastify is considered the stable release. Using fastify-raw-body in V2 will however result in the error:

node_modules/fastify-raw-body/node_modules/fastify-plugin/plugin.js: 67
  throw new Error(`fastify-plugin: ${pluginName} - expected '${version}' fastify version, '${fastifyVersion}' is installed`)

It looks like this plugin is only for V3.

Is it possible to make fastify-raw-body work on Fastify V2?

Motivation

There's a lot of Fastify V2 out there, and it will be a while before V3 is everywhere.

Thanks!

Eomm commented 4 years ago

I think it can with some less feature (I'm not sure I can tweak the order of execution that this PR https://github.com/fastify/fastify/pull/2286 added). Adjusting the preParsing hook interface I get # failed 4 of 14 tests.

I will try to arrange a version for it.

Eomm commented 4 years ago

I have released fastify-raw-body@fastify-2 aka fastify-raw-body@2.0.0 (the @latest tag will continue to support fastify v3, I'm going to release a v3 to fix this versioning)

Let me know if you have any trouble 👍

mikemaccana commented 4 years ago

Thanks! I'm playing with it today.

mikemaccana commented 4 years ago

This seems fine (we have a major release coming up, but should be able to pout this into production soon afterward) - it would be great to have TypeScript types but it seems to be working. 🙂

Eomm commented 4 years ago

Thanks for the feedback!