1 |
|
2 | import { Options, OptionsJson, OptionsText, OptionsUrlencoded } from 'body-parser';
|
3 | import { HttpError } from 'http-errors';
|
4 | import { Request, RequestBodyParserOptions, Response } from '../types';
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | export declare function getContentType(req: Request): string | undefined;
|
10 |
|
11 |
|
12 |
|
13 | export type BodyParserMiddleware = (request: Request, response: Response, next: (err: HttpError) => void) => void;
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | export declare function normalizeParsingError(err: HttpError): HttpError<number>;
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | export declare function invokeBodyParserMiddleware(handle: BodyParserMiddleware, request: Request): Promise<any>;
|
25 | export declare const DEFAULT_LIMIT = "1mb";
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | export declare function getParserOptions(type: 'json', options: RequestBodyParserOptions): OptionsJson;
|
32 | export declare function getParserOptions(type: 'urlencoded', options: RequestBodyParserOptions): OptionsUrlencoded;
|
33 | export declare function getParserOptions(type: 'text', options: RequestBodyParserOptions): OptionsText;
|
34 | export declare function getParserOptions(type: 'raw', options: RequestBodyParserOptions): Options;
|
35 | export declare namespace builtinParsers {
|
36 | const json: unique symbol;
|
37 | const urlencoded: unique symbol;
|
38 | const text: unique symbol;
|
39 | const raw: unique symbol;
|
40 | const stream: unique symbol;
|
41 | const names: (string | symbol)[];
|
42 | const mapping: {
|
43 | [name: string]: symbol;
|
44 | };
|
45 | }
|