@types/koa-bodyparser
TypeScript icon, indicating that this package has built-in type declarations

4.3.12 • Public • Published

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 * as Koa from "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: Tue, 07 Nov 2023 09:09:38 GMT
  • Dependencies: @types/koa

Credits

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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
4.3.12131,054ts5.7
4.3.12131,054ts5.6
4.3.12131,054latest
4.3.12131,054ts4.5
4.3.12131,054ts4.6
4.3.12131,054ts4.7
4.3.12131,054ts4.8
4.3.12131,054ts4.9
4.3.12131,054ts5.0
4.3.12131,054ts5.1
4.3.12131,054ts5.2
4.3.12131,054ts5.3
4.3.12131,054ts5.4
4.3.12131,054ts5.5
4.3.12131,054ts5.8
4.3.1070,507ts4.1
4.3.1070,507ts4.2
4.3.1070,507ts4.3
4.3.1070,507ts4.4
4.3.036,789ts2.3
4.3.036,789ts2.4
4.3.036,789ts2.5
4.3.036,789ts2.6
4.3.036,789ts2.7
4.3.036,789ts2.8
4.3.036,789ts2.9
4.3.036,789ts3.0
4.3.036,789ts3.1
4.3.036,789ts3.2
4.3.036,789ts3.3
4.3.036,789ts3.4
4.3.036,789ts3.5
4.3.718,194ts3.9
4.3.718,194ts4.0
4.3.36,794ts3.6
3.0.254,750ts2.0
3.0.254,750ts2.1
3.0.254,750ts2.2
4.3.54,140ts3.8
4.3.41,462ts3.7

Version History

VersionDownloads (Last 7 Days)Published
4.3.12131,054
4.3.114,017
4.3.1070,507
4.3.92,237
4.3.82,096
4.3.718,194
4.3.6729
4.3.54,140
4.3.41,462
4.3.36,794
4.3.22,172
4.3.1377
4.3.036,789
4.2.26,911
4.2.1347
5.0.27,719
5.0.1334
5.0.01
4.2.0823
3.0.26747
3.0.254,750
3.0.240
3.0.23178
3.0.220
3.0.210
3.0.209
3.0.190
3.0.180
3.0.17-alpha0
3.0.16-alpha0
3.0.15-alpha0
3.0.14-alpha0
3.0.13-alpha0
3.0.12-alpha0
3.0.11-alpha0
3.0.6-alpha0
3.0.5-alpha0

Package Sidebar

Install

npm i @types/koa-bodyparser

Weekly Downloads

302,387

Version

4.3.12

License

MIT

Unpacked Size

7.41 kB

Total Files

5

Last publish

Collaborators

  • types