@types/koa-bodyparser
TypeScript definitions for koa-bodyparser
Last updated 4 years ago by types .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install @types/koa-bodyparser 
SYNC missed versions from official npm registry.

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

// Type definitions for koa-bodyparser 4.3
// Project: https://github.com/koajs/body-parser
// Definitions by: Jerry Chin <https://github.com/hellopao>
//                 Hiroshi Ioka <https://github.com/hirochachacha>
//                 Alexi Maschas <https://github.com/amaschas>
//                 Pirasis Leelatanon <https://github.com/1pete>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3

/* =================== 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?: any;
        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
         */
        encode?: 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[] | undefined;
            form?: string[] | undefined;
            text?: string[] | undefined;
        } | undefined;

        /**
         * support custom error handle
         */
        onerror?: ((err: Error, ctx: Koa.Context) => void) | undefined;
    }
}

export = bodyParser;

Additional Details

  • Last updated: Thu, 23 Dec 2021 23:34:59 GMT
  • Dependencies: @types/koa
  • Global values: none

Credits

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

Current Tags

  • 4.3.5                                ...           latest (4 years ago)
  • 3.0.25                                ...           ts2.0 (9 years ago)
  • 3.0.25                                ...           ts2.1 (9 years ago)
  • 3.0.25                                ...           ts2.2 (9 years ago)
  • 4.3.0                                ...           ts2.3 (7 years ago)
  • 4.3.0                                ...           ts2.4 (7 years ago)
  • 4.3.0                                ...           ts2.5 (7 years ago)
  • 4.3.0                                ...           ts2.6 (7 years ago)
  • 4.3.0                                ...           ts2.7 (7 years ago)
  • 4.3.0                                ...           ts2.8 (7 years ago)
  • 4.3.0                                ...           ts2.9 (7 years ago)
  • 4.3.0                                ...           ts3.0 (7 years ago)
  • 4.3.0                                ...           ts3.1 (7 years ago)
  • 4.3.0                                ...           ts3.2 (7 years ago)
  • 4.3.0                                ...           ts3.3 (7 years ago)
  • 4.3.0                                ...           ts3.4 (7 years ago)
  • 4.3.0                                ...           ts3.5 (7 years ago)
  • 4.3.3                                ...           ts3.6 (5 years ago)
  • 4.3.4                                ...           ts3.7 (4 years ago)
  • 4.3.5                                ...           ts3.8 (4 years ago)
  • 4.3.5                                ...           ts3.9 (4 years ago)
  • 4.3.5                                ...           ts4.0 (4 years ago)
  • 4.3.5                                ...           ts4.1 (4 years ago)
  • 4.3.5                                ...           ts4.2 (4 years ago)
  • 4.3.5                                ...           ts4.3 (4 years ago)
  • 4.3.5                                ...           ts4.4 (4 years ago)
  • 4.3.5                                ...           ts4.5 (4 years ago)
  • 4.3.5                                ...           ts4.6 (4 years ago)

30 Versions

  • 4.3.5                                ...           4 years ago
  • 4.3.4                                ...           4 years ago
  • 4.3.3                                ...           5 years ago
  • 4.3.2                                ...           5 years ago
  • 4.3.1                                ...           5 years ago
  • 4.3.0                                ...           7 years ago
  • 4.2.2                                ...           7 years ago
  • 4.2.1                                ...           7 years ago
  • 5.0.2                                ...           7 years ago
  • 5.0.1                                ...           8 years ago
  • 5.0.0                                ...           8 years ago
  • 4.2.0                                ...           8 years ago
  • 3.0.26                                ...           8 years ago
  • 3.0.25                                ...           9 years ago
  • 3.0.24                                ...           9 years ago
  • 3.0.23                                ...           9 years ago
  • 3.0.22                                ...           9 years ago
  • 3.0.21                                ...           9 years ago
  • 3.0.20                                ...           10 years ago
  • 3.0.19                                ...           10 years ago
  • 3.0.18                                ...           10 years ago
  • 3.0.17-alpha                                ...           10 years ago
  • 3.0.16-alpha                                ...           10 years ago
  • 3.0.15-alpha                                ...           10 years ago
  • 3.0.14-alpha                                ...           10 years ago
  • 3.0.13-alpha                                ...           10 years ago
  • 3.0.12-alpha                                ...           10 years ago
  • 3.0.11-alpha                                ...           10 years ago
  • 3.0.6-alpha                                ...           10 years ago
  • 3.0.5-alpha                                ...           10 years ago
Maintainers (1)
Downloads
Today 1
This Week 2
This Month 2
Last Day 1
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (0)
None

Copyright 2013 - present © cnpmjs.org | Home |