Gathering detailed insights and metrics for koa-bodyparser
Gathering detailed insights and metrics for koa-bodyparser
Gathering detailed insights and metrics for koa-bodyparser
Gathering detailed insights and metrics for koa-bodyparser
npm install koa-bodyparser
Typescript
Module System
Min. Node Version
Node Version
NPM Version
97.6
Supply Chain
98.9
Quality
77.4
Maintenance
100
Vulnerability
100
License
TypeScript (100%)
Total Downloads
156,195,083
Last Day
35,108
Last Week
623,828
Last Month
2,754,708
Last Year
30,768,704
MIT License
1,320 Stars
116 Commits
121 Forks
20 Watchers
5 Branches
37 Contributors
Updated on Jun 05, 2025
Minified
Minified + Gzipped
Latest Version
4.4.1
Package Id
koa-bodyparser@4.4.1
Unpacked Size
14.69 kB
Size
5.69 kB
File Count
5
NPM Version
6.14.18
Node Version
18.16.0
Published on
Jun 22, 2023
Cumulative downloads
Total Downloads
Last Day
-0.1%
35,108
Compared to previous day
Last Week
-8%
623,828
Compared to previous week
Last Month
0.1%
2,754,708
Compared to previous month
Last Year
7.8%
30,768,704
Compared to previous year
A body parser for koa, based on co-body. support json
, form
and text
type body.
Notice: this module doesn't support parsing multipart format data, please use
@koa/multer
to parse multipart format data.
1const Koa = require('koa'); 2const bodyParser = require('koa-bodyparser'); 3 4const app = new Koa(); 5app.use(bodyParser()); 6 7app.use(async ctx => { 8 // the parsed body will store in ctx.request.body 9 // if nothing was parsed, body will be an empty object {} 10 ctx.body = ctx.request.body; 11});
enableTypes: parser will only parse when request type hits enableTypes, support json/form/text/xml
, default is ['json', 'form']
.
encoding: requested encoding. Default is utf-8
by co-body
.
formLimit: limit of the urlencoded
body. If the body ends up being larger than this limit, a 413 error code is returned. Default is 56kb
.
jsonLimit: limit of the json
body. Default is 1mb
.
textLimit: limit of the text
body. Default is 1mb
.
xmlLimit: limit of the xml
body. Default is 1mb
.
strict: when set to true, JSON parser will only accept arrays and objects. Default is true
. See strict mode in co-body
. In strict mode, ctx.request.body
will always be an object(or array), this avoid lots of type judging. But text body will always return string type.
detectJSON: custom json request detect function. Default is null
.
1app.use(bodyParser({ 2 detectJSON: function (ctx) { 3 return /\.json$/i.test(ctx.path); 4 } 5}));
extendTypes: support extend types:
1app.use(bodyParser({
2 extendTypes: {
3 json: ['application/x-javascript'] // will parse application/x-javascript type body as a JSON string
4 }
5}));
onerror: support custom error handle, if koa-bodyparser
throw an error, you can customize the response like:
1app.use(bodyParser({ 2 onerror: function (err, ctx) { 3 ctx.throw(422, 'body parse error'); 4 } 5}));
disableBodyParser: you can dynamic disable body parser by set ctx.disableBodyParser = true
.
1app.use(async (ctx, next) => { 2 if (ctx.path === '/disable') ctx.disableBodyParser = true; 3 await next(); 4}); 5app.use(bodyParser());
You can access raw request body by ctx.request.rawBody
after koa-bodyparser
when:
koa-bodyparser
parsed the request body.ctx.request.rawBody
is not present before koa-bodyparser
.To use koa-bodyparser
with koa@1, please use bodyparser 2.x.
1npm install koa-bodyparser@2 --save
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
6 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 5
Reason
Found 13/30 approved changesets -- score normalized to 4
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
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-30
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