@@ -16,92 +16,90 @@ import * as http from 'http';
16
16
17
17
// for docs go to https://github.com/expressjs/body-parser/tree/1.19.0#body-parser
18
18
19
- declare namespace bodyParser {
20
- interface BodyParser {
21
- /**
22
- * @deprecated use individual json/urlencoded middlewares
23
- */
24
- ( options ?: OptionsJson & OptionsText & OptionsUrlencoded ) : NextHandleFunction ;
25
- /**
26
- * Returns middleware that only parses json and only looks at requests
27
- * where the Content-Type header matches the type option.
28
- */
29
- json ( options ?: OptionsJson ) : NextHandleFunction ;
30
- /**
31
- * Returns middleware that parses all bodies as a Buffer and only looks at requests
32
- * where the Content-Type header matches the type option.
33
- */
34
- raw ( options ?: Options ) : NextHandleFunction ;
19
+ interface BodyParser {
20
+ /**
21
+ * @deprecated use individual json/urlencoded middlewares
22
+ */
23
+ ( options ?: OptionsJson & OptionsText & OptionsUrlencoded ) : NextHandleFunction ;
24
+ /**
25
+ * Returns middleware that only parses json and only looks at requests
26
+ * where the Content-Type header matches the type option.
27
+ */
28
+ json ( options ?: OptionsJson ) : NextHandleFunction ;
29
+ /**
30
+ * Returns middleware that parses all bodies as a Buffer and only looks at requests
31
+ * where the Content-Type header matches the type option.
32
+ */
33
+ raw ( options ?: Options ) : NextHandleFunction ;
35
34
36
- /**
37
- * Returns middleware that parses all bodies as a string and only looks at requests
38
- * where the Content-Type header matches the type option.
39
- */
40
- text ( options ?: OptionsText ) : NextHandleFunction ;
41
- /**
42
- * Returns middleware that only parses urlencoded bodies and only looks at requests
43
- * where the Content-Type header matches the type option
44
- */
45
- urlencoded ( options ?: OptionsUrlencoded ) : NextHandleFunction ;
46
- }
35
+ /**
36
+ * Returns middleware that parses all bodies as a string and only looks at requests
37
+ * where the Content-Type header matches the type option.
38
+ */
39
+ text ( options ?: OptionsText ) : NextHandleFunction ;
40
+ /**
41
+ * Returns middleware that only parses urlencoded bodies and only looks at requests
42
+ * where the Content-Type header matches the type option
43
+ */
44
+ urlencoded ( options ?: OptionsUrlencoded ) : NextHandleFunction ;
45
+ }
47
46
48
- interface Options {
49
- /** When set to true, then deflated (compressed) bodies will be inflated; when false, deflated bodies are rejected. Defaults to true. */
50
- inflate ?: boolean | undefined ;
51
- /**
52
- * Controls the maximum request body size. If this is a number,
53
- * then the value specifies the number of bytes; if it is a string,
54
- * the value is passed to the bytes library for parsing. Defaults to '100kb'.
55
- */
56
- limit ?: number | string | undefined ;
57
- /**
58
- * The type option is used to determine what media type the middleware will parse
59
- */
60
- type ?: string | string [ ] | ( ( req : http . IncomingMessage ) => any ) | undefined ;
61
- /**
62
- * The verify option, if supplied, is called as verify(req, res, buf, encoding),
63
- * where buf is a Buffer of the raw request body and encoding is the encoding of the request.
64
- */
65
- verify ?( req : http . IncomingMessage , res : http . ServerResponse , buf : Buffer , encoding : string ) : void ;
66
- }
47
+ interface Options {
48
+ /** When set to true, then deflated (compressed) bodies will be inflated; when false, deflated bodies are rejected. Defaults to true. */
49
+ inflate ?: boolean | undefined ;
50
+ /**
51
+ * Controls the maximum request body size. If this is a number,
52
+ * then the value specifies the number of bytes; if it is a string,
53
+ * the value is passed to the bytes library for parsing. Defaults to '100kb'.
54
+ */
55
+ limit ?: number | string | undefined ;
56
+ /**
57
+ * The type option is used to determine what media type the middleware will parse
58
+ */
59
+ type ?: string | string [ ] | ( ( req : http . IncomingMessage ) => any ) | undefined ;
60
+ /**
61
+ * The verify option, if supplied, is called as verify(req, res, buf, encoding),
62
+ * where buf is a Buffer of the raw request body and encoding is the encoding of the request.
63
+ */
64
+ verify ?( req : http . IncomingMessage , res : http . ServerResponse , buf : Buffer , encoding : string ) : void ;
65
+ }
67
66
68
- interface OptionsJson extends Options {
69
- /**
70
- *
71
- * The reviver option is passed directly to JSON.parse as the second argument.
72
- */
73
- reviver ?( key : string , value : any ) : any ;
74
- /**
75
- * When set to `true`, will only accept arrays and objects;
76
- * when `false` will accept anything JSON.parse accepts. Defaults to `true`.
77
- */
78
- strict ?: boolean | undefined ;
79
- }
67
+ interface OptionsJson extends Options {
68
+ /**
69
+ *
70
+ * The reviver option is passed directly to JSON.parse as the second argument.
71
+ */
72
+ reviver ?( key : string , value : any ) : any ;
73
+ /**
74
+ * When set to `true`, will only accept arrays and objects;
75
+ * when `false` will accept anything JSON.parse accepts. Defaults to `true`.
76
+ */
77
+ strict ?: boolean | undefined ;
78
+ }
80
79
81
- interface OptionsText extends Options {
82
- /**
83
- * Specify the default character set for the text content if the charset
84
- * is not specified in the Content-Type header of the request.
85
- * Defaults to `utf-8`.
86
- */
87
- defaultCharset ?: string | undefined ;
88
- }
80
+ interface OptionsText extends Options {
81
+ /**
82
+ * Specify the default character set for the text content if the charset
83
+ * is not specified in the Content-Type header of the request.
84
+ * Defaults to `utf-8`.
85
+ */
86
+ defaultCharset ?: string | undefined ;
87
+ }
89
88
90
- interface OptionsUrlencoded extends Options {
91
- /**
92
- * The extended option allows to choose between parsing the URL-encoded data
93
- * with the querystring library (when `false`) or the qs library (when `true`).
94
- */
95
- extended ?: boolean | undefined ;
96
- /**
97
- * The parameterLimit option controls the maximum number of parameters
98
- * that are allowed in the URL-encoded data. If a request contains more parameters than this value,
99
- * a 413 will be returned to the client. Defaults to 1000.
100
- */
101
- parameterLimit ?: number | undefined ;
102
- }
89
+ interface OptionsUrlencoded extends Options {
90
+ /**
91
+ * The extended option allows to choose between parsing the URL-encoded data
92
+ * with the querystring library (when `false`) or the qs library (when `true`).
93
+ */
94
+ extended ?: boolean | undefined ;
95
+ /**
96
+ * The parameterLimit option controls the maximum number of parameters
97
+ * that are allowed in the URL-encoded data. If a request contains more parameters than this value,
98
+ * a 413 will be returned to the client. Defaults to 1000.
99
+ */
100
+ parameterLimit ?: number | undefined ;
103
101
}
104
102
105
- declare const bodyParser : bodyParser . BodyParser ;
103
+ declare const bodyParser : BodyParser ;
106
104
107
105
export = bodyParser ;
0 commit comments