Skip to content

Remove unnecessary body-parser dependency#283

Merged
slifty merged 2 commits intomainfrom
noissue-remove-body-parser
Sep 3, 2025
Merged

Remove unnecessary body-parser dependency#283
slifty merged 2 commits intomainfrom
noissue-remove-body-parser

Conversation

@slifty
Copy link
Collaborator

@slifty slifty commented May 2, 2025

This PR removes an unnecessary dependency (Express provides a native version of .json() middleware now)

Resolves #284

@slifty slifty marked this pull request as draft May 5, 2025 16:12
@cecilia-donnelly
Copy link
Member

Did you two decide not to move forward with this?

@slifty
Copy link
Collaborator Author

slifty commented Jul 22, 2025

@cecilia-donnelly you know what, I didn't -- I just forgot I had started it after pulling into another priority at the time.

I'll finish this up shortly. What's missing is the replacement of the middleware (I took out body parser but didn't add back express.json())

@slifty slifty force-pushed the noissue-remove-body-parser branch 2 times, most recently from 073d915 to ad1e2fc Compare July 23, 2025 19:15
Express now natively supports `.json` so we don't need to use the
body-parser's version of the middleware.

Issue #284 Removing body-parser
@liam-lloyd liam-lloyd force-pushed the noissue-remove-body-parser branch 2 times, most recently from e0d461e to 0e8245f Compare September 3, 2025 22:42
Before switching to the express.json() middleware, empty requests bodies
were represented by empty objects, meaning middleware that added things
to the request body was always able to do so. Now, however, empty
request bodies are undefined, meaning such middleware fails. This commit
adds an extra piece of middleware to run after express.json() and set
request.body to {} if it is undefined, allowing the rest of the
middleware to run successfully. Note that this is a stopgap, we should
eventually update all the middleware not to modify the request body.
@liam-lloyd liam-lloyd force-pushed the noissue-remove-body-parser branch from 0e8245f to 621b13e Compare September 3, 2025 22:43
@codecov
Copy link

codecov bot commented Sep 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.22%. Comparing base (6b5f57e) to head (621b13e).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #283   +/-   ##
=======================================
  Coverage   98.21%   98.22%           
=======================================
  Files         101      101           
  Lines        2414     2417    +3     
  Branches      401      400    -1     
=======================================
+ Hits         2371     2374    +3     
  Misses         39       39           
  Partials        4        4           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@liam-lloyd
Copy link
Member

I'd like to be rid of body-parser, particularly because of the bizarre destroy bug in our local envs, so I've added what I think is the last piece necessary to merge this. Note that what I've done is a stopgap; we should remove it after this ticket is completed

@liam-lloyd liam-lloyd marked this pull request as ready for review September 3, 2025 22:59
@slifty
Copy link
Collaborator Author

slifty commented Sep 3, 2025

@liam-lloyd oh brilliant patch thank you!

I'm going to review to approve your portion ;)

@slifty
Copy link
Collaborator Author

slifty commented Sep 3, 2025

Oh, I can't review my own PR (this makes sense)

Which is to say: @liam-lloyd if you wanna review + approve I'll merge!

@slifty slifty merged commit 3b2d672 into main Sep 3, 2025
4 checks passed
@slifty slifty deleted the noissue-remove-body-parser branch September 3, 2025 23:53
@cecilia-donnelly
Copy link
Member

🎉 🎉 🎉

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 this pull request may close these issues.

Removing body-parser

3 participants

Comments