question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom response middleware without `body-parser`

See original GitHub issue

As first discussed here, in version 1.3.5 there is a breaking change (commit) that affects custom response middleware.

body-parser was added before the custom middleware, which means that the request is consumed before it can reach the custom code. This means that the ‘data’ and ‘end’ request events are no longer called in the custom code. See this issue for a better explanation. Maybe revert to the old code (let the response unaltered) and add a config option to enable parsing the JSON body for you?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
vudodovcommented, Aug 8, 2019

Thank you for taking care of it. Since body-parser is a default tool used to parse body, I’ve added a small PR to unlock its more detailed configuration

1reaction
muratcorlucommented, Aug 8, 2019

Yes, you are right. I’ll try to check if it’s easy to do. And if so, I’ll do the fix today.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parsing JSON in Express without BodyParser - Stack Overflow
I think the problem like to get rawBody in express. Just like this: app.use(function(req, res, next){ var data = ""; req.on('data', ...
Read more >
Express body-parser middleware
Node.js body parsing middleware. Parse incoming request bodies in a middleware before your handlers, available under the req.body property. Note As ...
Read more >
Express JS— body-parser and why may not need it - Medium
This piece of middleware was called body-parser and used to not be part of the Express framework. The good news is that as...
Read more >
Use body-parser Express Middleware to Parse JSON and ...
We can parse JSON bodies by calling the JSON method. It takes an optional object with a few properties. The options include: ......
Read more >
Middleware and Helpers - Gatsby
Data formats; Response helpers; Custom middleware; Custom body parsing ... This object allows you to control the body-parser middleware used by Gatsby ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found