1+ // Type definitions for body-parser
2+ // Project: http://expressjs.com
3+ // Definitions by: Santi Albo <https://github.com/santialbo/>, VILIC VANE <https://vilic.info>, Jonathan Häberle <https://github.com/dreampulse/>
4+ // Definitions: https://github.com/borisyankov/DefinitelyTyped
5+
6+ /// <reference path="../express/express.d.ts" />
7+
8+ declare module "body-parser" {
9+ import * as express from "express" ;
10+
11+ /**
12+ * bodyParser: use individual json/urlencoded middlewares
13+ * @deprecated
14+ */
15+
16+ function bodyParser ( options ?: {
17+ /**
18+ * if deflated bodies will be inflated. (default: true)
19+ */
20+ inflate ?: boolean ;
21+ /**
22+ * maximum request body size. (default: '100kb')
23+ */
24+ limit ?: any ;
25+ /**
26+ * function to verify body content, the parsing can be aborted by throwing an error.
27+ */
28+ verify ?: ( req : express . Request , res : express . Response , buf : Buffer , encoding : string ) => void ;
29+ /**
30+ * only parse objects and arrays. (default: true)
31+ */
32+ strict ?: boolean ;
33+ /**
34+ * passed to JSON.parse().
35+ */
36+ receiver ?: ( key : string , value : any ) => any ;
37+ /**
38+ * parse extended syntax with the qs module. (default: true)
39+ */
40+ extended ?: boolean ;
41+ } ) : express . RequestHandler ;
42+
43+ module bodyParser {
44+ export function json ( options ?: {
45+ /**
46+ * if deflated bodies will be inflated. (default: true)
47+ */
48+ inflate ?: boolean ;
49+ /**
50+ * maximum request body size. (default: '100kb')
51+ */
52+ limit ?: any ;
53+ /**
54+ * request content-type to parse, passed directly to the type-is library. (default: 'json')
55+ */
56+ type ?: any ;
57+ /**
58+ * function to verify body content, the parsing can be aborted by throwing an error.
59+ */
60+ verify ?: ( req : express . Request , res : express . Response , buf : Buffer , encoding : string ) => void ;
61+ /**
62+ * only parse objects and arrays. (default: true)
63+ */
64+ strict ?: boolean ;
65+ /**
66+ * passed to JSON.parse().
67+ */
68+ receiver ?: ( key : string , value : any ) => any ;
69+ } ) : express . RequestHandler ;
70+
71+ export function raw ( options ?: {
72+ /**
73+ * if deflated bodies will be inflated. (default: true)
74+ */
75+ inflate ?: boolean ;
76+ /**
77+ * maximum request body size. (default: '100kb')
78+ */
79+ limit ?: any ;
80+ /**
81+ * request content-type to parse, passed directly to the type-is library. (default: 'application/octet-stream')
82+ */
83+ type ?: any ;
84+ /**
85+ * function to verify body content, the parsing can be aborted by throwing an error.
86+ */
87+ verify ?: ( req : express . Request , res : express . Response , buf : Buffer , encoding : string ) => void ;
88+ } ) : express . RequestHandler ;
89+
90+ export function text ( options ?: {
91+ /**
92+ * if deflated bodies will be inflated. (default: true)
93+ */
94+ inflate ?: boolean ;
95+ /**
96+ * maximum request body size. (default: '100kb')
97+ */
98+ limit ?: any ;
99+ /**
100+ * request content-type to parse, passed directly to the type-is library. (default: 'text/plain')
101+ */
102+ type ?: any ;
103+ /**
104+ * function to verify body content, the parsing can be aborted by throwing an error.
105+ */
106+ verify ?: ( req : express . Request , res : express . Response , buf : Buffer , encoding : string ) => void ;
107+ /**
108+ * the default charset to parse as, if not specified in content-type. (default: 'utf-8')
109+ */
110+ defaultCharset ?: string ;
111+ } ) : express . RequestHandler ;
112+
113+ export function urlencoded ( options ?: {
114+ /**
115+ * if deflated bodies will be inflated. (default: true)
116+ */
117+ inflate ?: boolean ;
118+ /**
119+ * maximum request body size. (default: '100kb')
120+ */
121+ limit ?: any ;
122+ /**
123+ * request content-type to parse, passed directly to the type-is library. (default: 'urlencoded')
124+ */
125+ type ?: any ;
126+ /**
127+ * function to verify body content, the parsing can be aborted by throwing an error.
128+ */
129+ verify ?: ( req : express . Request , res : express . Response , buf : Buffer , encoding : string ) => void ;
130+ /**
131+ * parse extended syntax with the qs module. (default: true)
132+ */
133+ extended ?: boolean ;
134+ } ) : express . RequestHandler ;
135+ }
136+
137+ export = bodyParser ;
138+ }
0 commit comments