forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
koa-bodyparser.d.ts
65 lines (50 loc) · 1.63 KB
/
koa-bodyparser.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Type definitions for koa-bodyparser v3.x
// Project: https://github.com/koajs/bodyparser
// Definitions by: Jerry Chin <https://github.com/hellopao/>
// Definitions: https://github.com/hellopao/DefinitelyTyped
/* =================== USAGE ===================
import bodyParser = require("koa-bodyparser");
var Koa = require('koa');
var app = new Koa();
app.use(bodyParser());
=============================================== */
/// <reference path="../koa/koa.d.ts" />
declare module "koa-bodyparser" {
import * as Koa from "koa";
function bodyParser(opts?: {
/**
* requested encoding. Default is utf-8 by co-body
*/
encode?: string;
/**
* 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;
/**
* limit of the json body. Default is 1mb
*/
jsonLimit?: string;
/**
* when set to true, JSON parser will only accept arrays and objects. Default is true
*/
strict?: boolean;
/**
* custom json request detect function. Default is null
*/
detectJSON?: (ctx: Koa.Context) => boolean;
/**
* support extend types
*/
extendTypes?: {
json?: string[];
form?: string[];
}
/**
* support custom error handle
*/
onerror?: (err: Error, ctx: Koa.Context) => void;
}): { (ctx: Koa.Context, next?: () => any): any };
namespace bodyParser {}
export = bodyParser;
}