Option to skip parsing
What is the problem this feature would solve?
Some routes, as mentioned in the documentation, don't require automatic body parsing at all and break if it occurs because the body is used due to side effects introduced by plugins (i.e. how elysia works)
What is the feature you are proposing to solve the problem?
Allow parse: false option in the route's configuration, or reconsider parsing for plugins that don't access the body but Context
app.post("/", betterAuthView, {
parse: false,
});
Allowing something like this should also improve performance
What alternatives have you considered?
I tried this, but it is inconsistent with aot: false, in some cases and bad UX:
app.post("/", betterAuthView, {
parse: () => 0,
});
Also would appreciate this - we just ran into a case where we wanted to write a POST handler that doesn't have a body. We can't change the method for backwards compatibility reasons
Also would like this. A third party package does a await req.body.text() which results in an "body already in use" if it was already parsed
Never mind I see from the linked issue I can do:
body: t.String(),
parse: ctx => {
const cloned = ctx.request.clone()
return cloned.text()
}
new Elysia().get(
'/',
({ body }) => body ?? 'no body?',
{
parse: 'none',
}
)