🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

@types/koa-bodyparser

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/koa-bodyparser

TypeScript definitions for koa-bodyparser

ts5.2
ts5.3
ts5.4
ts5.5
ts5.6
ts5.7
ts5.8
ts5.9
ts6.0
latest
Source
npmnpm
Version
4.3.13
Version published
Weekly downloads
453K
4.39%
Maintainers
1
Weekly downloads
 
Created
Source

Installation

npm install --save @types/koa-bodyparser

Summary

This package contains type definitions for koa-bodyparser (https://github.com/koajs/body-parser).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/koa-bodyparser.

index.d.ts

/* =================== 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;

Additional Details

  • Last updated: Fri, 24 Oct 2025 04:02:41 GMT
  • Dependencies: @types/koa

Credits

These definitions were written by Jerry Chin, Hiroshi Ioka, Alexi Maschas, and Pirasis Leelatanon.

FAQs

Package last updated on 24 Oct 2025

Did you know?

Socket

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.

Install

Related posts