Skip to content

basalt / express/src / captureRawBody

Function: captureRawBody() ​

> captureRawBody(req, _res, buf): void

Defined in: express/src/index.ts:205

A body-parser verify hook that keeps the untouched bytes for rawBody() routes. expressPlugin installs it automatically on the parsers it mounts; pass it yourself when you bring your own app with its own parsers:

ts
app.use(express.json({ verify: captureRawBody }))
app.use(express.urlencoded({ extended: false, verify: captureRawBody }))

It only stores a reference to the buffer body-parser has already allocated, so it costs nothing beyond keeping it alive for the length of the request.

Parameters ​

req ​

unknown

_res ​

unknown

buf ​

Buffer

Returns ​

void

Released under the MIT License.