1 |
|
2 |
|
3 | import { NextHandleFunction } from "connect";
|
4 | import * as http from "http";
|
5 |
|
6 |
|
7 |
|
8 | declare namespace bodyParser {
|
9 | interface BodyParser {
|
10 | |
11 |
|
12 |
|
13 | (options?: OptionsJson & OptionsText & OptionsUrlencoded): NextHandleFunction;
|
14 | |
15 |
|
16 |
|
17 |
|
18 | json(options?: OptionsJson): NextHandleFunction;
|
19 | |
20 |
|
21 |
|
22 |
|
23 | raw(options?: Options): NextHandleFunction;
|
24 |
|
25 | |
26 |
|
27 |
|
28 |
|
29 | text(options?: OptionsText): NextHandleFunction;
|
30 | |
31 |
|
32 |
|
33 |
|
34 | urlencoded(options?: OptionsUrlencoded): NextHandleFunction;
|
35 | }
|
36 |
|
37 | interface Options {
|
38 |
|
39 | inflate?: boolean | undefined;
|
40 | |
41 |
|
42 |
|
43 |
|
44 |
|
45 | limit?: number | string | undefined;
|
46 | |
47 |
|
48 |
|
49 | type?: string | string[] | ((req: http.IncomingMessage) => any) | undefined;
|
50 | /**
|
51 | * The verify option, if supplied, is called as verify(req, res, buf, encoding),
|
52 | * where buf is a Buffer of the raw request body and encoding is the encoding of the request.
|
53 | */
|
54 | verify?(req: http.IncomingMessage, res: http.ServerResponse, buf: Buffer, encoding: string): void;
|
55 | }
|
56 |
|
57 | interface OptionsJson extends Options {
|
58 | /**
|
59 | * The reviver option is passed directly to JSON.parse as the second argument.
|
60 | */
|
61 | reviver?(key: string, value: any): any;
|
62 | /**
|
63 | * When set to `true`, will only accept arrays and objects;
|
64 | * when `false` will accept anything JSON.parse accepts. Defaults to `true`.
|
65 | */
|
66 | strict?: boolean | undefined;
|
67 | }
|
68 |
|
69 | interface OptionsText extends Options {
|
70 | /**
|
71 | * Specify the default character set for the text content if the charset
|
72 | * is not specified in the Content-Type header of the request.
|
73 | * Defaults to `utf-8`.
|
74 | */
|
75 | defaultCharset?: string | undefined;
|
76 | }
|
77 |
|
78 | interface OptionsUrlencoded extends Options {
|
79 | /**
|
80 | * The extended option allows to choose between parsing the URL-encoded data
|
81 | * with the querystring library (when `false`) or the qs library (when `true`).
|
82 | */
|
83 | extended?: boolean | undefined;
|
84 | /**
|
85 | * The parameterLimit option controls the maximum number of parameters
|
86 | * that are allowed in the URL-encoded data. If a request contains more parameters than this value,
|
87 | * a 413 will be returned to the client. Defaults to 1000.
|
88 | */
|
89 | parameterLimit?: number | undefined;
|
90 | }
|
91 | }
|
92 |
|
93 | declare const bodyParser: bodyParser.BodyParser;
|
94 |
|
95 | export = bodyParser;
|
96 |
|
\ | No newline at end of file |