UNPKG

4.41 kBTypeScriptView Raw
1/* =================== USAGE ===================
2
3 import express = require("express");
4 var app = express();
5
6 =============================================== */
7
8/// <reference types="express-serve-static-core" />
9/// <reference types="serve-static" />
10
11import * as bodyParser from "body-parser";
12import * as core from "express-serve-static-core";
13import * as qs from "qs";
14import * as serveStatic from "serve-static";
15
16/**
17 * Creates an Express application. The express() function is a top-level function exported by the express module.
18 */
19declare function e(): core.Express;
20
21declare namespace e {
22 /**
23 * This is a built-in middleware function in Express. It parses incoming requests with JSON payloads and is based on body-parser.
24 * @since 4.16.0
25 */
26 var json: typeof bodyParser.json;
27
28 /**
29 * This is a built-in middleware function in Express. It parses incoming requests with Buffer payloads and is based on body-parser.
30 * @since 4.17.0
31 */
32 var raw: typeof bodyParser.raw;
33
34 /**
35 * This is a built-in middleware function in Express. It parses incoming requests with text payloads and is based on body-parser.
36 * @since 4.17.0
37 */
38 var text: typeof bodyParser.text;
39
40 /**
41 * These are the exposed prototypes.
42 */
43 var application: Application;
44 var request: Request;
45 var response: Response;
46
47 /**
48 * This is a built-in middleware function in Express. It serves static files and is based on serve-static.
49 */
50 var static: serveStatic.RequestHandlerConstructor<Response>;
51
52 /**
53 * This is a built-in middleware function in Express. It parses incoming requests with urlencoded payloads and is based on body-parser.
54 * @since 4.16.0
55 */
56 var urlencoded: typeof bodyParser.urlencoded;
57
58 /**
59 * This is a built-in middleware function in Express. It parses incoming request query parameters.
60 */
61 export function query(options: qs.IParseOptions | typeof qs.parse): Handler;
62
63 export function Router(options?: RouterOptions): core.Router;
64
65 interface RouterOptions {
66 /**
67 * Enable case sensitivity.
68 */
69 caseSensitive?: boolean | undefined;
70
71 /**
72 * Preserve the req.params values from the parent router.
73 * If the parent and the child have conflicting param names, the child’s value take precedence.
74 *
75 * @default false
76 * @since 4.5.0
77 */
78 mergeParams?: boolean | undefined;
79
80 /**
81 * Enable strict routing.
82 */
83 strict?: boolean | undefined;
84 }
85
86 interface Application extends core.Application {}
87 interface CookieOptions extends core.CookieOptions {}
88 interface Errback extends core.Errback {}
89 interface ErrorRequestHandler<
90 P = core.ParamsDictionary,
91 ResBody = any,
92 ReqBody = any,
93 ReqQuery = core.Query,
94 Locals extends Record<string, any> = Record<string, any>,
95 > extends core.ErrorRequestHandler<P, ResBody, ReqBody, ReqQuery, Locals> {}
96 interface Express extends core.Express {}
97 interface Handler extends core.Handler {}
98 interface IRoute extends core.IRoute {}
99 interface IRouter extends core.IRouter {}
100 interface IRouterHandler<T> extends core.IRouterHandler<T> {}
101 interface IRouterMatcher<T> extends core.IRouterMatcher<T> {}
102 interface MediaType extends core.MediaType {}
103 interface NextFunction extends core.NextFunction {}
104 interface Locals extends core.Locals {}
105 interface Request<
106 P = core.ParamsDictionary,
107 ResBody = any,
108 ReqBody = any,
109 ReqQuery = core.Query,
110 Locals extends Record<string, any> = Record<string, any>,
111 > extends core.Request<P, ResBody, ReqBody, ReqQuery, Locals> {}
112 interface RequestHandler<
113 P = core.ParamsDictionary,
114 ResBody = any,
115 ReqBody = any,
116 ReqQuery = core.Query,
117 Locals extends Record<string, any> = Record<string, any>,
118 > extends core.RequestHandler<P, ResBody, ReqBody, ReqQuery, Locals> {}
119 interface RequestParamHandler extends core.RequestParamHandler {}
120 interface Response<
121 ResBody = any,
122 Locals extends Record<string, any> = Record<string, any>,
123 > extends core.Response<ResBody, Locals> {}
124 interface Router extends core.Router {}
125 interface Send extends core.Send {}
126}
127
128export = e;