fastify / fastify/fastify-multipart

Compatibility with preParsing / onRequest hooks

Open
#620 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
539
Forks
126
PR merge metrics
No merged PRs in 30d

Description

### Prerequisites

- [x] I have written a descriptive issue title
- [x] I have searched existing issues to ensure the feature has not already been requested

### 🚀 Feature Proposal

As far as I can tell, this plugin reads from `request.raw`:

https://github.com/fastify/fastify-multipart/blob/60e1b5ca627602c7e1fbf12209ec2af0828b8dc0/index.js#L263

In my usecase, which is verifying webhook signatures from Sendgrid, I'll need to have the raw binary body so that the webhook can be verified, but then parse the body as multipart. Getting both of these right does not appear to be possible with how fastify-multipart is set up right now.

If I use `preParsing` and read the request stream to verify it, then this plugin looks and finds the request stream empty and closed by the time it gets to the verification hook.

### Motivation

Making this plugin more intuitive to use with other hooks - it did not occur to me for a long time that my preParsing hook which followed documented patterns would not work because this plugin was reading from req.raw instead of reading the payload stream.

### Example

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.