Closed xxRockOnxx closed 1 year ago
I created a small middleware function to support already parsed bodies:
function hybridBodyParser (opts) {
const bp = bodyParser(opts)
return async (ctx, next) => {
ctx.request.body = ctx.request.body || ctx.req.body
return bp(ctx, next)
}
}
Usage:
app.use(hybridBodyParser())
I created a small middleware function to support already parsed bodies:
function hybridBodyParser (opts) { const bp = bodyParser(opts) return async (ctx, next) => { ctx.request.body = ctx.request.body || ctx.req.body return bp(ctx, next) } }
Usage:
app.use(hybridBodyParser())
@dead-horse, @niftylettuce What do you think of adding this to the README.md file !!
I am strongly against using anything like Firebase. It is up to @dead-horse on this.
Using this on firebase does not make any sense since it'll not do anything. Firebase does it already. Although I know how to workaround this now, a warning on README would be appreciated by those who haven't come across this yet.
Submit a PR for review
I have already published a blog talking about this here and I will include this in my PR (#152) for the next release.
I have added a new option enableRawChecking
to support the already parsed body by checking the raw request ctx.req.body
if it contains values (code).
I would say, we published @koa/bodyparser v5 a few minutes ago. So you can now use the enableRawChecking
option.
This is really puzzling because you can't really figure out why it's giving a Timeout.
No errors or warnings.
Fortunately, I stumbled upon this stackoverflow question: https://stackoverflow.com/questions/58237305/post-request-hangs-timeout-when-trying-to-parse-request-body-running-koa-on-f
And according to the solution written there:
Shouldn't this package handle the said problem?
EDIT:
I mean at least a warning to prevent confusion if it can't do it. It doesn't make sense to use this package if the body is already parsed wouldn't it?