forked from jbaroudi/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
body-parser.d.ts
138 lines (129 loc) · 4.76 KB
/
body-parser.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// Type definitions for body-parser
// Project: http://expressjs.com
// Definitions by: Santi Albo <https://github.com/santialbo/>, VILIC VANE <https://vilic.info>, Jonathan Häberle <https://github.com/dreampulse/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../express/express.d.ts" />
declare module "body-parser" {
import * as express from "express";
/**
* bodyParser: use individual json/urlencoded middlewares
* @deprecated
*/
function bodyParser(options?: {
/**
* if deflated bodies will be inflated. (default: true)
*/
inflate?: boolean;
/**
* maximum request body size. (default: '100kb')
*/
limit?: any;
/**
* function to verify body content, the parsing can be aborted by throwing an error.
*/
verify?: (req: express.Request, res: express.Response, buf: Buffer, encoding: string) => void;
/**
* only parse objects and arrays. (default: true)
*/
strict?: boolean;
/**
* passed to JSON.parse().
*/
receiver?: (key: string, value: any) => any;
/**
* parse extended syntax with the qs module. (default: true)
*/
extended?: boolean;
}): express.RequestHandler;
module bodyParser {
export function json(options?: {
/**
* if deflated bodies will be inflated. (default: true)
*/
inflate?: boolean;
/**
* maximum request body size. (default: '100kb')
*/
limit?: any;
/**
* request content-type to parse, passed directly to the type-is library. (default: 'json')
*/
type?: any;
/**
* function to verify body content, the parsing can be aborted by throwing an error.
*/
verify?: (req: express.Request, res: express.Response, buf: Buffer, encoding: string) => void;
/**
* only parse objects and arrays. (default: true)
*/
strict?: boolean;
/**
* passed to JSON.parse().
*/
receiver?: (key: string, value: any) => any;
}): express.RequestHandler;
export function raw(options?: {
/**
* if deflated bodies will be inflated. (default: true)
*/
inflate?: boolean;
/**
* maximum request body size. (default: '100kb')
*/
limit?: any;
/**
* request content-type to parse, passed directly to the type-is library. (default: 'application/octet-stream')
*/
type?: any;
/**
* function to verify body content, the parsing can be aborted by throwing an error.
*/
verify?: (req: express.Request, res: express.Response, buf: Buffer, encoding: string) => void;
}): express.RequestHandler;
export function text(options?: {
/**
* if deflated bodies will be inflated. (default: true)
*/
inflate?: boolean;
/**
* maximum request body size. (default: '100kb')
*/
limit?: any;
/**
* request content-type to parse, passed directly to the type-is library. (default: 'text/plain')
*/
type?: any;
/**
* function to verify body content, the parsing can be aborted by throwing an error.
*/
verify?: (req: express.Request, res: express.Response, buf: Buffer, encoding: string) => void;
/**
* the default charset to parse as, if not specified in content-type. (default: 'utf-8')
*/
defaultCharset?: string;
}): express.RequestHandler;
export function urlencoded(options: {
/**
* if deflated bodies will be inflated. (default: true)
*/
inflate?: boolean;
/**
* maximum request body size. (default: '100kb')
*/
limit?: any;
/**
* request content-type to parse, passed directly to the type-is library. (default: 'urlencoded')
*/
type?: any;
/**
* function to verify body content, the parsing can be aborted by throwing an error.
*/
verify?: (req: express.Request, res: express.Response, buf: Buffer, encoding: string) => void;
/**
* parse extended syntax with the qs module.
*/
extended: boolean;
}): express.RequestHandler;
}
export = bodyParser;
}