Gathering detailed insights and metrics for fastify-raw-body
Gathering detailed insights and metrics for fastify-raw-body
Gathering detailed insights and metrics for fastify-raw-body
Gathering detailed insights and metrics for fastify-raw-body
npm install fastify-raw-body
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.3
Supply Chain
92.1
Quality
76.1
Maintenance
100
Vulnerability
100
License
JavaScript (95.49%)
TypeScript (4.51%)
Total Downloads
7,903,382
Last Day
15,194
Last Week
77,912
Last Month
317,682
Last Year
3,419,628
MIT License
47 Stars
63 Commits
10 Forks
2 Watchers
2 Branches
9 Contributors
Updated on Apr 14, 2025
Minified
Minified + Gzipped
Latest Version
5.0.0
Package Id
fastify-raw-body@5.0.0
Unpacked Size
25.33 kB
Size
5.83 kB
File Count
8
NPM Version
10.1.0
Node Version
20.8.0
Published on
Sep 17, 2024
Cumulative downloads
Total Downloads
Last Day
57%
15,194
Compared to previous day
Last Week
13.6%
77,912
Compared to previous week
Last Month
-3.5%
317,682
Compared to previous month
Last Year
50.6%
3,419,628
Compared to previous year
3
5
Adds the raw body to the Fastify request object.
npm i fastify-raw-body
Plugin version | Fastify version |
---|---|
^5.0.0 | ^5.0.0 |
^4.2.1 | ^4.19.0 |
^4.0.0 | ^4.0.0 |
^3.0.0 | ^3.0.0 |
^2.0.0 | ^2.0.0 |
This plugin will add the request.rawBody
.
It will get the data using the preParsing
hook.
1import Fastify from 'fastify' 2 3const app = Fastify() 4await app.register(import('fastify-raw-body'), { 5 field: 'rawBody', // change the default request.rawBody property name 6 global: false, // add the rawBody to every request. **Default true** 7 encoding: 'utf8', // set it to false to set rawBody as a Buffer **Default utf8** 8 runFirst: true, // get the body before any preParsing hook change/uncompress it. **Default false** 9 routes: [], // array of routes, **`global`** will be ignored, wildcard routes not supported 10 jsonContentTypes: [], // array of content-types to handle as JSON. **Default ['application/json']** 11}) 12 13app.post('/', { 14 config: { 15 // add the rawBody to this route. if false, rawBody will be disabled when global is true 16 rawBody: true 17 }, 18 handler (req, reply) { 19 // req.rawBody the string raw body 20 reply.send(req.rawBody) 21 } 22})
Note
You need toawait
the plugin registration to make sure the plugin is ready to use. All the routes defined before the plugin registration will be ignored. This change has been introduced in Fastify v4.
Warning
Settingglobal: false
and then the route configuration{ config: { rawBody: true } }
will save memory of your server since therawBody
is a copy of thebody
and it will double the memory usage.
So use it only for the routes that you need to.
It is important to know that setting encoding: false
will run addContentTypeParser
to add a content type parser for application/json
.
This is needed since the default content type parser will set the encoding of the request stream to { parseAs: 'string' }
.
If you haven't customized this component, it will be secure as the original one since secure-json-parse
is used under the hood.
Copyright Manuel Spigolon, Licensed under MIT.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 3/12 approved changesets -- score normalized to 2
Reason
2 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 2
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-05-05
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More