
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
@types/koa-bodyparser
Advanced tools
TypeScript definitions for koa-bodyparser
npm install --save @types/koa-bodyparser
This package contains type definitions for koa-bodyparser (https://github.com/koajs/body-parser).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/koa-bodyparser.
/* =================== USAGE ===================
import bodyParser = require("koa-bodyparser");
var Koa = require('koa');
var app = new Koa();
app.use(bodyParser());
=============================================== */
import Koa = require("koa");
declare module "koa" {
interface Request {
body?: unknown;
rawBody: string;
}
}
declare function bodyParser(opts?: bodyParser.Options): Koa.Middleware;
declare namespace bodyParser {
interface Options {
/**
* parser will only parse when request type hits enableTypes, default is ['json', 'form'].
*/
enableTypes?: string[] | undefined;
/**
* requested encoding. Default is utf-8 by co-body
*/
encoding?: string | undefined;
/**
* limit of the urlencoded body. If the body ends up being larger than this limit
* a 413 error code is returned. Default is 56kb
*/
formLimit?: string | undefined;
/**
* limit of the json body. Default is 1mb
*/
jsonLimit?: string | undefined;
/**
* limit of the text body. Default is 1mb.
*/
textLimit?: string | undefined;
/**
* limit of the xml body. Default is 1mb.
*/
xmlLimit?: string | undefined;
/**
* when set to true, JSON parser will only accept arrays and objects. Default is true
*/
strict?: boolean | undefined;
/**
* custom json request detect function. Default is null
*/
detectJSON?: ((ctx: Koa.Context) => boolean) | undefined;
/**
* support extend types
*/
extendTypes?: {
json?: string[] | string | undefined;
form?: string[] | string | undefined;
text?: string[] | string | undefined;
} | undefined;
/**
* support custom error handle
*/
onerror?: ((err: Error, ctx: Koa.Context) => void) | undefined;
}
}
export = bodyParser;
These definitions were written by Jerry Chin, Hiroshi Ioka, Alexi Maschas, and Pirasis Leelatanon.
koa-body is a more comprehensive body parser middleware for Koa that supports multipart, urlencoded, and JSON request bodies. It offers more features compared to koa-bodyparser, such as file uploads and custom handling of multipart requests.
koa-multer is a middleware for handling multipart/form-data, which is primarily used for uploading files. It is based on multer and provides more advanced file handling capabilities compared to koa-bodyparser.
koa-json-body is a simpler alternative to koa-bodyparser that focuses solely on parsing JSON request bodies. It is lightweight and easy to use but lacks the flexibility of handling other content types.
FAQs
TypeScript definitions for koa-bodyparser
The npm package @types/koa-bodyparser receives a total of 435,935 weekly downloads. As such, @types/koa-bodyparser popularity was classified as popular.
We found that @types/koa-bodyparser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.