Gathering detailed insights and metrics for koa-bodyparser-ts
Gathering detailed insights and metrics for koa-bodyparser-ts
Gathering detailed insights and metrics for koa-bodyparser-ts
Gathering detailed insights and metrics for koa-bodyparser-ts
npm install koa-bodyparser-ts
Typescript
Module System
Min. Node Version
Node Version
NPM Version
67.7
Supply Chain
91.8
Quality
73
Maintenance
100
Vulnerability
100
License
TypeScript (98.15%)
JavaScript (1.85%)
Total Downloads
65,199
Last Day
36
Last Week
181
Last Month
473
Last Year
7,160
MIT License
7 Stars
72 Commits
6 Watchers
229 Branches
2 Contributors
Updated on Jul 18, 2022
Minified
Minified + Gzipped
Latest Version
0.3.1
Package Id
koa-bodyparser-ts@0.3.1
Unpacked Size
31.25 kB
Size
7.30 kB
File Count
8
NPM Version
5.6.0
Node Version
8.11.1
Cumulative downloads
Total Downloads
Last Day
0%
36
Compared to previous day
Last Week
105.7%
181
Compared to previous week
Last Month
17.1%
473
Compared to previous month
Last Year
6.1%
7,160
Compared to previous year
4
1
A body parser for koa, base on co-body. support json
, form
and text
type body.
npm install koa-bodyparser-ts --save
1 2import * as Koa from "koa"; 3import bodyParser from "koa-bodyparser-ts"; 4 5const app = new Koa(); 6app.use(bodyParser()); 7 8app.use(async ctx => { 9 // the parsed body will store in ctx.request.body 10 // if nothing was parsed, body will be an empty object {} 11 ctx.body = ctx.request.body; 12});
enableTypes: parser will only parse when request type hits enableTypes, default is ['json', 'form']
.
encode: 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
.
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('body parse error', 422); 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
.No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/22 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
73 existing vulnerabilities detected
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