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

fix(express,fastify): raw body for urlencoded requests #9926

Merged
merged 1 commit into from Jul 20, 2022

Conversation

tolgap
Copy link
Contributor

@tolgap tolgap commented Jul 13, 2022

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #9901

What is the new behavior?

Registers raw body for application/x-www-form-urlencoded requests.

Does this PR introduce a breaking change?

  • Yes
  • No

@fastify/formbody did not allow any customization in the parsing process. Looking at the source code of that package, shows that it is incredibly small. In order to add req.rawBody, most of the code had to be duplicated. So I made the choice to remove registration fastify/formbody, and handle the content type ourselves in the exact same way. Only difference: the req.rawBody also gets assigned if the option was set.

Keen eyes will also notice that I've added support for bodyLimit when registering these content parsers. The previous code (of mine) was missing this.

Other information

Question:
We do not use @fastify/formbody anywere after these changes. Should I remove it from package.json and package-lock.json?

@coveralls
Copy link

Pull Request Test Coverage Report for Build c2db15da-bc1e-408b-8ee0-9f415cba4cd6

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 94.089%

Totals Coverage Status
Change from base Build af61eabc-eb97-4a47-a92d-55a521601a44: 0.0%
Covered Lines: 6049
Relevant Lines: 6429

💛 - Coveralls

@kamilmysliwiec
Copy link
Member

We do not use @fastify/formbody anywere after these changes. Should I remove it from package.json and package-lock.json?

I'll remove it! Thanks for pointing this out.

LGTM 🔥

@kamilmysliwiec kamilmysliwiec merged commit 4eacd87 into nestjs:master Jul 20, 2022
@tolgap tolgap deleted the fix/9901-urlencoded-raw-body branch February 1, 2023 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants