@tsed/platform-express 6.88.1 → 6.89.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{components → cjs/components}/PlatformExpress.d.ts +0 -0
- package/lib/{components → cjs/components}/PlatformExpress.js +1 -1
- package/lib/cjs/components/PlatformExpress.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/caseSensitive.d.ts +0 -0
- package/lib/{decorators → cjs/decorators}/caseSensitive.js +1 -1
- package/lib/cjs/decorators/caseSensitive.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/index.d.ts +0 -0
- package/lib/cjs/decorators/index.js +8 -0
- package/lib/cjs/decorators/index.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/mergeParams.d.ts +0 -0
- package/lib/{decorators → cjs/decorators}/mergeParams.js +1 -1
- package/lib/cjs/decorators/mergeParams.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/routerSettings.d.ts +0 -0
- package/lib/{decorators → cjs/decorators}/routerSettings.js +1 -1
- package/lib/cjs/decorators/routerSettings.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/strict.d.ts +0 -0
- package/lib/{decorators → cjs/decorators}/strict.js +1 -1
- package/lib/cjs/decorators/strict.js.map +1 -0
- package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
- package/lib/{index.js → cjs/index.js} +4 -4
- package/lib/cjs/index.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/PlatformExpressSettings.d.ts +0 -0
- package/lib/{interfaces → cjs/interfaces}/PlatformExpressSettings.js +0 -0
- package/lib/cjs/interfaces/PlatformExpressSettings.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/PlatformExpressStaticsOptions.d.ts +0 -0
- package/lib/{interfaces → cjs/interfaces}/PlatformExpressStaticsOptions.js +0 -0
- package/lib/cjs/interfaces/PlatformExpressStaticsOptions.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/index.d.ts +0 -0
- package/lib/cjs/interfaces/index.js +6 -0
- package/lib/cjs/interfaces/index.js.map +1 -0
- package/lib/{middlewares → cjs/middlewares}/rawBodyMiddleware.d.ts +0 -0
- package/lib/{middlewares → cjs/middlewares}/rawBodyMiddleware.js +1 -1
- package/lib/cjs/middlewares/rawBodyMiddleware.js.map +1 -0
- package/lib/{middlewares → cjs/middlewares}/staticsMiddleware.d.ts +0 -0
- package/lib/{middlewares → cjs/middlewares}/staticsMiddleware.js +1 -1
- package/lib/cjs/middlewares/staticsMiddleware.js.map +1 -0
- package/lib/{services → cjs/services}/PlatformExpressApplication.d.ts +0 -0
- package/lib/{services → cjs/services}/PlatformExpressApplication.js +6 -5
- package/lib/cjs/services/PlatformExpressApplication.js.map +1 -0
- package/lib/{services → cjs/services}/PlatformExpressHandler.d.ts +0 -0
- package/lib/{services → cjs/services}/PlatformExpressHandler.js +0 -0
- package/lib/cjs/services/PlatformExpressHandler.js.map +1 -0
- package/lib/{services → cjs/services}/PlatformExpressRequest.d.ts +0 -0
- package/lib/{services → cjs/services}/PlatformExpressRequest.js +0 -0
- package/lib/cjs/services/PlatformExpressRequest.js.map +1 -0
- package/lib/{services → cjs/services}/PlatformExpressResponse.d.ts +0 -0
- package/lib/{services → cjs/services}/PlatformExpressResponse.js +0 -0
- package/lib/cjs/services/PlatformExpressResponse.js.map +1 -0
- package/lib/{services → cjs/services}/PlatformExpressRouter.d.ts +0 -0
- package/lib/{services → cjs/services}/PlatformExpressRouter.js +6 -6
- package/lib/cjs/services/PlatformExpressRouter.js.map +1 -0
- package/lib/{services → cjs/services}/index.d.ts +0 -0
- package/lib/cjs/services/index.js +9 -0
- package/lib/cjs/services/index.js.map +1 -0
- package/lib/esm/components/PlatformExpress.js +108 -0
- package/lib/esm/components/PlatformExpress.js.map +1 -0
- package/lib/esm/decorators/caseSensitive.js +27 -0
- package/lib/esm/decorators/caseSensitive.js.map +1 -0
- package/lib/esm/decorators/index.js +5 -0
- package/lib/esm/decorators/index.js.map +1 -0
- package/lib/esm/decorators/mergeParams.js +27 -0
- package/lib/esm/decorators/mergeParams.js.map +1 -0
- package/lib/esm/decorators/routerSettings.js +28 -0
- package/lib/esm/decorators/routerSettings.js.map +1 -0
- package/lib/esm/decorators/strict.js +27 -0
- package/lib/esm/decorators/strict.js.map +1 -0
- package/lib/esm/index.js +13 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/interfaces/PlatformExpressSettings.js +2 -0
- package/lib/esm/interfaces/PlatformExpressSettings.js.map +1 -0
- package/lib/esm/interfaces/PlatformExpressStaticsOptions.js +2 -0
- package/lib/esm/interfaces/PlatformExpressStaticsOptions.js.map +1 -0
- package/lib/esm/interfaces/index.js +3 -0
- package/lib/esm/interfaces/index.js.map +1 -0
- package/lib/esm/middlewares/rawBodyMiddleware.js +22 -0
- package/lib/esm/middlewares/rawBodyMiddleware.js.map +1 -0
- package/lib/esm/middlewares/staticsMiddleware.js +16 -0
- package/lib/esm/middlewares/staticsMiddleware.js.map +1 -0
- package/lib/esm/services/PlatformExpressApplication.js +29 -0
- package/lib/esm/services/PlatformExpressApplication.js.map +1 -0
- package/lib/esm/services/PlatformExpressHandler.js +27 -0
- package/lib/esm/services/PlatformExpressHandler.js.map +1 -0
- package/lib/esm/services/PlatformExpressRequest.js +8 -0
- package/lib/esm/services/PlatformExpressRequest.js.map +1 -0
- package/lib/esm/services/PlatformExpressResponse.js +8 -0
- package/lib/esm/services/PlatformExpressResponse.js.map +1 -0
- package/lib/esm/services/PlatformExpressRouter.js +31 -0
- package/lib/esm/services/PlatformExpressRouter.js.map +1 -0
- package/lib/esm/services/index.js +6 -0
- package/lib/esm/services/index.js.map +1 -0
- package/lib/types/components/PlatformExpress.d.ts +39 -0
- package/lib/types/decorators/caseSensitive.d.ts +23 -0
- package/lib/types/decorators/index.d.ts +4 -0
- package/lib/types/decorators/mergeParams.d.ts +23 -0
- package/lib/types/decorators/routerSettings.d.ts +24 -0
- package/lib/types/decorators/strict.d.ts +23 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/interfaces/PlatformExpressSettings.d.ts +9 -0
- package/lib/types/interfaces/PlatformExpressStaticsOptions.d.ts +63 -0
- package/lib/types/interfaces/index.d.ts +16 -0
- package/lib/types/middlewares/rawBodyMiddleware.d.ts +4 -0
- package/lib/types/middlewares/staticsMiddleware.d.ts +4 -0
- package/lib/types/services/PlatformExpressApplication.d.ts +24 -0
- package/lib/types/services/PlatformExpressHandler.d.ts +9 -0
- package/lib/types/services/PlatformExpressRequest.d.ts +22 -0
- package/lib/types/services/PlatformExpressResponse.d.ts +14 -0
- package/lib/types/services/PlatformExpressRouter.d.ts +18 -0
- package/lib/types/services/index.d.ts +5 -0
- package/package.json +27 -19
- package/tsconfig.compile.esm.json +23 -0
- package/lib/components/PlatformExpress.js.map +0 -1
- package/lib/decorators/caseSensitive.js.map +0 -1
- package/lib/decorators/index.js +0 -8
- package/lib/decorators/index.js.map +0 -1
- package/lib/decorators/mergeParams.js.map +0 -1
- package/lib/decorators/routerSettings.js.map +0 -1
- package/lib/decorators/strict.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/interfaces/PlatformExpressSettings.js.map +0 -1
- package/lib/interfaces/PlatformExpressStaticsOptions.js.map +0 -1
- package/lib/interfaces/index.js +0 -6
- package/lib/interfaces/index.js.map +0 -1
- package/lib/middlewares/rawBodyMiddleware.js.map +0 -1
- package/lib/middlewares/staticsMiddleware.js.map +0 -1
- package/lib/services/PlatformExpressApplication.js.map +0 -1
- package/lib/services/PlatformExpressHandler.js.map +0 -1
- package/lib/services/PlatformExpressRequest.js.map +0 -1
- package/lib/services/PlatformExpressResponse.js.map +0 -1
- package/lib/services/PlatformExpressRouter.js.map +0 -1
- package/lib/services/index.js +0 -9
- package/lib/services/index.js.map +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RouterSettings } from "./routerSettings";
|
|
2
|
+
/**
|
|
3
|
+
* Specify the behavior of the router controller.
|
|
4
|
+
*
|
|
5
|
+
* ```typescript
|
|
6
|
+
* @Controller("/")
|
|
7
|
+
* @Strict(true)
|
|
8
|
+
* class MyCtrl {
|
|
9
|
+
*
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Property | Description | Default
|
|
14
|
+
* ---|---|---
|
|
15
|
+
* CaseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.
|
|
16
|
+
* MergeParams | Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child’s value take precedence. | false
|
|
17
|
+
* Strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.
|
|
18
|
+
*
|
|
19
|
+
* @param strict
|
|
20
|
+
* @returns {Function}
|
|
21
|
+
* @decorator
|
|
22
|
+
* @express
|
|
23
|
+
*/
|
|
24
|
+
export function Strict(strict) {
|
|
25
|
+
return RouterSettings({ strict });
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=strict.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strict.js","sourceRoot":"","sources":["../../../src/decorators/strict.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,MAAM,CAAC,MAAe;IACpC,OAAO,cAAc,CAAC,EAAC,MAAM,EAAC,CAAC,CAAC;AAClC,CAAC","sourcesContent":["import {RouterSettings} from \"./routerSettings\";\n\n/**\n * Specify the behavior of the router controller.\n *\n * ```typescript\n * @Controller(\"/\")\n * @Strict(true)\n * class MyCtrl {\n *\n * }\n * ```\n *\n * Property | Description | Default\n * ---|---|---\n * CaseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.\n * MergeParams | Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child’s value take precedence. | false\n * Strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.\n *\n * @param strict\n * @returns {Function}\n * @decorator\n * @express\n */\nexport function Strict(strict: boolean) {\n return RouterSettings({strict});\n}\n"]}
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PlatformBuilder, PlatformTest } from "@tsed/common";
|
|
2
|
+
import { PlatformExpress } from "./components/PlatformExpress";
|
|
3
|
+
PlatformTest.platformBuilder = PlatformExpress;
|
|
4
|
+
PlatformBuilder.currentPlatform = PlatformExpress;
|
|
5
|
+
// interfaces
|
|
6
|
+
export * from "./interfaces";
|
|
7
|
+
// decorators
|
|
8
|
+
export * from "./decorators";
|
|
9
|
+
// services
|
|
10
|
+
export * from "./services";
|
|
11
|
+
// components
|
|
12
|
+
export * from "./components/PlatformExpress";
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAE7D,YAAY,CAAC,eAAe,GAAG,eAAe,CAAC;AAC/C,eAAe,CAAC,eAAe,GAAG,eAAsB,CAAC;AAEzD,aAAa;AACb,cAAc,cAAc,CAAC;AAE7B,aAAa;AACb,cAAc,cAAc,CAAC;AAE7B,WAAW;AACX,cAAc,YAAY,CAAC;AAE3B,aAAa;AACb,cAAc,8BAA8B,CAAC","sourcesContent":["import {PlatformBuilder, PlatformTest} from \"@tsed/common\";\n\nimport {PlatformExpress} from \"./components/PlatformExpress\";\n\nPlatformTest.platformBuilder = PlatformExpress;\nPlatformBuilder.currentPlatform = PlatformExpress as any;\n\n// interfaces\nexport * from \"./interfaces\";\n\n// decorators\nexport * from \"./decorators\";\n\n// services\nexport * from \"./services\";\n\n// components\nexport * from \"./components/PlatformExpress\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformExpressSettings.js","sourceRoot":"","sources":["../../../src/interfaces/PlatformExpressSettings.ts"],"names":[],"mappings":"","sourcesContent":["import {RouterOptions} from \"express\";\n\nexport interface PlatformExpressSettings {\n /**\n * Global configuration for the Express.Router. See express [documentation](http://expressjs.com/en/api.html#express.router).\n */\n router?: RouterOptions;\n\n app?: Express.Application;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformExpressStaticsOptions.js","sourceRoot":"","sources":["../../../src/interfaces/PlatformExpressStaticsOptions.ts"],"names":[],"mappings":"","sourcesContent":["import Express from \"express\";\n\nexport interface PlatformExpressStaticsOptions {\n /**\n * Enable or disable setting Cache-Control response header, defaults to true.\n * Disabling this will ignore the immutable and maxAge options.\n */\n cacheControl?: boolean;\n\n /**\n * Set how \"dotfiles\" are treated when encountered. A dotfile is a file or directory that begins with a dot (\".\").\n * Note this check is done on the path itself without checking if the path actually exists on the disk.\n * If root is specified, only the dotfiles above the root are checked (i.e. the root itself can be within a dotfile when when set to \"deny\").\n * The default value is 'ignore'.\n * 'allow' No special treatment for dotfiles\n * 'deny' Send a 403 for any request for a dotfile\n * 'ignore' Pretend like the dotfile does not exist and call next()\n */\n dotfiles?: string;\n\n /**\n * Enable or disable etag generation, defaults to true.\n */\n etag?: boolean;\n\n /**\n * Set file extension fallbacks. When set, if a file is not found, the given extensions will be added to the file name and search for.\n * The first that exists will be served. Example: ['html', 'htm'].\n * The default value is false.\n */\n extensions?: string[] | false;\n\n /**\n * Let client errors fall-through as unhandled requests, otherwise forward a client error.\n * The default value is true.\n */\n fallthrough?: boolean;\n\n /**\n * Enable or disable the immutable directive in the Cache-Control response header.\n * If enabled, the maxAge option should also be specified to enable caching. The immutable directive will prevent supported clients from making conditional requests during the life of the maxAge option to check if the file has changed.\n */\n immutable?: boolean;\n\n /**\n * By default this module will send \"index.html\" files in response to a request on a directory.\n * To disable this set false or to supply a new index pass a string or an array in preferred order.\n */\n index?: boolean | string | string[];\n\n /**\n * Enable or disable Last-Modified header, defaults to true. Uses the file system's last modified value.\n */\n lastModified?: boolean;\n\n /**\n * Provide a max-age in milliseconds for http caching, defaults to 0. This can also be a string accepted by the ms module.\n */\n maxAge?: number | string;\n\n /**\n * Redirect to trailing \"/\" when the pathname is a dir. Defaults to true.\n */\n redirect?: boolean;\n\n /**\n * Function to set custom headers on response. Alterations to the headers need to occur synchronously.\n * The function is called as fn(res, path, stat), where the arguments are:\n * res the response object\n * path the file path that is being sent\n * stat the stat object of the file that is being sent\n */\n setHeaders?: (res: Express.Response, path: string, stat: any) => any;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":"AAGA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC","sourcesContent":["import Express from \"express\";\nimport {PlatformExpressSettings} from \"./PlatformExpressSettings\";\n\nexport * from \"./PlatformExpressSettings\";\nexport * from \"./PlatformExpressStaticsOptions\";\n\ndeclare global {\n namespace TsED {\n export interface Configuration {\n /**\n * Configuration related to Express platform application.\n */\n express: PlatformExpressSettings;\n }\n\n export interface NextFunction extends Express.NextFunction {}\n }\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import bytes from "bytes";
|
|
2
|
+
const limit = bytes.parse("100kb");
|
|
3
|
+
function isLimitReached(length) {
|
|
4
|
+
return limit !== null && length !== null && length > limit;
|
|
5
|
+
}
|
|
6
|
+
function getContentLength(request) {
|
|
7
|
+
const contentLength = request.get("content-length");
|
|
8
|
+
return contentLength != null && !isNaN(contentLength) ? parseInt(contentLength, 10) : null;
|
|
9
|
+
}
|
|
10
|
+
export function rawBodyMiddleware(request, response, next) {
|
|
11
|
+
if (request.method !== "GET") {
|
|
12
|
+
const length = getContentLength(request);
|
|
13
|
+
if (!isLimitReached(length) && request.is(["application/x-www-form-urlencoded", "application/json"])) {
|
|
14
|
+
request.rawBody = "";
|
|
15
|
+
request.on("data", (chunk) => {
|
|
16
|
+
request.rawBody += chunk;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
next();
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=rawBodyMiddleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rawBodyMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/rawBodyMiddleware.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAEnC,SAAS,cAAc,CAAC,MAAqB;IAC3C,OAAO,KAAK,KAAK,IAAI,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,GAAG,KAAK,CAAC;AAC7D,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAoC;IAC5D,MAAM,aAAa,GAAQ,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACzD,OAAO,aAAa,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7F,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAoC,EAAE,QAAa,EAAE,IAAS;IAC9F,IAAI,OAAO,CAAC,MAAM,KAAK,KAAK,EAAE;QAC5B,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAEzC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,EAAE,CAAC,CAAC,mCAAmC,EAAE,kBAAkB,CAAC,CAAC,EAAE;YACpG,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC;YACrB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;gBACnC,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC;YAC3B,CAAC,CAAC,CAAC;SACJ;KACF;IAED,IAAI,EAAE,CAAC;AACT,CAAC","sourcesContent":["import {Request} from \"express\";\nimport bytes from \"bytes\";\n\nconst limit = bytes.parse(\"100kb\");\n\nfunction isLimitReached(length: number | null) {\n return limit !== null && length !== null && length > limit;\n}\n\nfunction getContentLength(request: Request & {rawBody: string}) {\n const contentLength: any = request.get(\"content-length\");\n return contentLength != null && !isNaN(contentLength) ? parseInt(contentLength, 10) : null;\n}\n\nexport function rawBodyMiddleware(request: Request & {rawBody: string}, response: any, next: any) {\n if (request.method !== \"GET\") {\n const length = getContentLength(request);\n\n if (!isLimitReached(length) && request.is([\"application/x-www-form-urlencoded\", \"application/json\"])) {\n request.rawBody = \"\";\n request.on(\"data\", (chunk: string) => {\n request.rawBody += chunk;\n });\n }\n }\n\n next();\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Express from "express";
|
|
2
|
+
/**
|
|
3
|
+
* @ignore
|
|
4
|
+
*/
|
|
5
|
+
export function staticsMiddleware(directory, options = {}) {
|
|
6
|
+
const middleware = Express.static(directory, options);
|
|
7
|
+
return (request, response, next) => {
|
|
8
|
+
if (!response.headersSent) {
|
|
9
|
+
middleware(request, response, next);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
next();
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=staticsMiddleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staticsMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/staticsMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAiB,EAAE,UAAe,EAAE;IACpE,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAEtD,OAAO,CAAC,OAAY,EAAE,QAAa,EAAE,IAAS,EAAE,EAAE;QAChD,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE;YACzB,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;SACrC;aAAM;YACL,IAAI,EAAE,CAAC;SACR;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import Express from \"express\";\n\n/**\n * @ignore\n */\nexport function staticsMiddleware(directory: string, options: any = {}) {\n const middleware = Express.static(directory, options);\n\n return (request: any, response: any, next: any) => {\n if (!response.headersSent) {\n middleware(request, response, next);\n } else {\n next();\n }\n };\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { __decorate, __metadata, __param } from "tslib";
|
|
2
|
+
import { Configuration, Inject, PlatformHandler } from "@tsed/common";
|
|
3
|
+
import Express from "express";
|
|
4
|
+
import { PlatformExpressRouter } from "./PlatformExpressRouter";
|
|
5
|
+
/**
|
|
6
|
+
* @platform
|
|
7
|
+
* @express
|
|
8
|
+
*/
|
|
9
|
+
let PlatformExpressApplication = class PlatformExpressApplication extends PlatformExpressRouter {
|
|
10
|
+
constructor(platformHandler, configuration) {
|
|
11
|
+
super(platformHandler, configuration, {
|
|
12
|
+
mergeParams: true
|
|
13
|
+
});
|
|
14
|
+
this.rawApp = configuration.get("express.app") || Express();
|
|
15
|
+
}
|
|
16
|
+
getApp() {
|
|
17
|
+
return this.rawApp;
|
|
18
|
+
}
|
|
19
|
+
callback() {
|
|
20
|
+
return this.rawApp;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
PlatformExpressApplication = __decorate([
|
|
24
|
+
__param(0, Inject()),
|
|
25
|
+
__param(1, Configuration()),
|
|
26
|
+
__metadata("design:paramtypes", [PlatformHandler, Object])
|
|
27
|
+
], PlatformExpressApplication);
|
|
28
|
+
export { PlatformExpressApplication };
|
|
29
|
+
//# sourceMappingURL=PlatformExpressApplication.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformExpressApplication.js","sourceRoot":"","sources":["../../../src/services/PlatformExpressApplication.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,aAAa,EAAiB,MAAM,EAAuB,eAAe,EAAC,MAAM,cAAc,CAAC;AACxG,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAU9D;;;GAGG;AACH,IAAa,0BAA0B,GAAvC,MAAa,0BAA2B,SAAQ,qBAAqB;IAKnE,YAAsB,eAAgC,EAAmB,aAA4B;QACnG,KAAK,CAAC,eAAe,EAAE,aAAa,EAAE;YACpC,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,OAAO,EAAE,CAAC;IAC9D,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF,CAAA;AApBY,0BAA0B;IAKxB,WAAA,MAAM,EAAE,CAAA;IAAoC,WAAA,aAAa,EAAE,CAAA;qCAAjC,eAAe;GAL3C,0BAA0B,CAoBtC;SApBY,0BAA0B","sourcesContent":["import {Configuration, createContext, Inject, PlatformApplication, PlatformHandler} from \"@tsed/common\";\nimport Express from \"express\";\nimport {PlatformExpressStaticsOptions} from \"../interfaces/PlatformExpressStaticsOptions\";\nimport {PlatformExpressRouter} from \"./PlatformExpressRouter\";\n\ndeclare global {\n namespace TsED {\n export interface Application extends Express.Application {}\n\n export interface StaticsOptions extends PlatformExpressStaticsOptions {}\n }\n}\n\n/**\n * @platform\n * @express\n */\nexport class PlatformExpressApplication extends PlatformExpressRouter implements PlatformApplication<Express.Application, Express.Router> {\n app: Express.Application;\n rawApp: Express.Application;\n rawRouter: Express.Router;\n\n constructor(@Inject() platformHandler: PlatformHandler, @Configuration() configuration: Configuration) {\n super(platformHandler, configuration, {\n mergeParams: true\n });\n\n this.rawApp = configuration.get(\"express.app\") || Express();\n }\n\n getApp() {\n return this.rawApp;\n }\n\n callback() {\n return this.rawApp;\n }\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { HandlerType, PlatformHandler } from "@tsed/common";
|
|
2
|
+
/**
|
|
3
|
+
* @platform
|
|
4
|
+
* @express
|
|
5
|
+
*/
|
|
6
|
+
export class PlatformExpressHandler extends PlatformHandler {
|
|
7
|
+
createRawHandler(metadata) {
|
|
8
|
+
if (metadata.type === HandlerType.ERR_MIDDLEWARE) {
|
|
9
|
+
const handler = this.compileHandler(metadata);
|
|
10
|
+
return async (err, req, res, next) => handler({
|
|
11
|
+
err,
|
|
12
|
+
next,
|
|
13
|
+
$ctx: req.$ctx
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return super.createRawHandler(metadata);
|
|
17
|
+
}
|
|
18
|
+
async onCtxRequest(requestOptions) {
|
|
19
|
+
try {
|
|
20
|
+
return await super.onCtxRequest(requestOptions);
|
|
21
|
+
}
|
|
22
|
+
catch (er) {
|
|
23
|
+
return this.onError(er, requestOptions);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=PlatformExpressHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformExpressHandler.js","sourceRoot":"","sources":["../../../src/services/PlatformExpressHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAoB,eAAe,EAAC,MAAM,cAAc,CAAC;AAE7F;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,eAAe;IAC/C,gBAAgB,CAAC,QAAyB;QAClD,IAAI,QAAQ,CAAC,IAAI,KAAK,WAAW,CAAC,cAAc,EAAE;YAChD,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;YAC9C,OAAO,KAAK,EAAE,GAAQ,EAAE,GAAQ,EAAE,GAAQ,EAAE,IAAS,EAAE,EAAE,CACvD,OAAO,CAAC;gBACN,GAAG;gBACH,IAAI;gBACJ,IAAI,EAAE,GAAG,CAAC,IAAI;aACf,CAAC,CAAC;SACN;QAED,OAAO,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAES,KAAK,CAAC,YAAY,CAAC,cAAgC;QAC3D,IAAI;YACF,OAAO,MAAM,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;SACjD;QAAC,OAAO,EAAE,EAAE;YACX,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;SACzC;IACH,CAAC;CACF","sourcesContent":["import {HandlerMetadata, HandlerType, OnRequestOptions, PlatformHandler} from \"@tsed/common\";\n\n/**\n * @platform\n * @express\n */\nexport class PlatformExpressHandler extends PlatformHandler {\n protected createRawHandler(metadata: HandlerMetadata): Function {\n if (metadata.type === HandlerType.ERR_MIDDLEWARE) {\n const handler = this.compileHandler(metadata);\n return async (err: any, req: any, res: any, next: any) =>\n handler({\n err,\n next,\n $ctx: req.$ctx\n });\n }\n\n return super.createRawHandler(metadata);\n }\n\n protected async onCtxRequest(requestOptions: OnRequestOptions): Promise<any> {\n try {\n return await super.onCtxRequest(requestOptions);\n } catch (er) {\n return this.onError(er, requestOptions);\n }\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformExpressRequest.js","sourceRoot":"","sources":["../../../src/services/PlatformExpressRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,eAAe,EAAC,MAAM,cAAc,CAAC;AAmB9D;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,eAAgC;CAAG","sourcesContent":["import {PlatformContext, PlatformRequest} from \"@tsed/common\";\nimport type Express from \"express\";\n\ndeclare module \"express\" {\n export interface Request {\n id: string;\n $ctx: PlatformContext;\n }\n}\n\ndeclare global {\n namespace TsED {\n export interface Request extends Express.Request {\n id: string;\n $ctx: PlatformContext;\n }\n }\n}\n\n/**\n * @platform\n * @express\n */\nexport class PlatformExpressRequest extends PlatformRequest<Express.Request> {}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformExpressResponse.js","sourceRoot":"","sources":["../../../src/services/PlatformExpressResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAS9C;;;GAGG;AACH,MAAM,OAAO,uBAAwB,SAAQ,gBAAkC;CAAG","sourcesContent":["import {PlatformResponse} from \"@tsed/common\";\nimport type Express from \"express\";\n\ndeclare global {\n namespace TsED {\n export interface Response extends Express.Response {}\n }\n}\n\n/**\n * @platform\n * @express\n */\nexport class PlatformExpressResponse extends PlatformResponse<Express.Response> {}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { __decorate, __metadata, __param } from "tslib";
|
|
2
|
+
import { PLATFORM_ROUTER_OPTIONS, PlatformHandler, PlatformRouter } from "@tsed/common";
|
|
3
|
+
import { Configuration, Inject } from "@tsed/di";
|
|
4
|
+
import Express from "express";
|
|
5
|
+
import { staticsMiddleware } from "../middlewares/staticsMiddleware";
|
|
6
|
+
/**
|
|
7
|
+
* @platform
|
|
8
|
+
* @express
|
|
9
|
+
*/
|
|
10
|
+
let PlatformExpressRouter = class PlatformExpressRouter extends PlatformRouter {
|
|
11
|
+
constructor(platform, configuration, routerOptions = {}) {
|
|
12
|
+
var _a;
|
|
13
|
+
super(platform);
|
|
14
|
+
const options = Object.assign({
|
|
15
|
+
mergeParams: true
|
|
16
|
+
}, ((_a = configuration.express) === null || _a === void 0 ? void 0 : _a.router) || {}, routerOptions);
|
|
17
|
+
this.rawRouter = this.raw = Express.Router(options);
|
|
18
|
+
}
|
|
19
|
+
statics(endpoint, options) {
|
|
20
|
+
const { root, ...props } = options;
|
|
21
|
+
this.use(endpoint, staticsMiddleware(root, props));
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
PlatformExpressRouter = __decorate([
|
|
26
|
+
__param(1, Configuration()),
|
|
27
|
+
__param(2, Inject(PLATFORM_ROUTER_OPTIONS)),
|
|
28
|
+
__metadata("design:paramtypes", [PlatformHandler, Object, Object])
|
|
29
|
+
], PlatformExpressRouter);
|
|
30
|
+
export { PlatformExpressRouter };
|
|
31
|
+
//# sourceMappingURL=PlatformExpressRouter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformExpressRouter.js","sourceRoot":"","sources":["../../../src/services/PlatformExpressRouter.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,uBAAuB,EAAE,eAAe,EAAE,cAAc,EAAyB,MAAM,cAAc,CAAC;AAC9G,OAAO,EAAC,aAAa,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AAC/C,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAC,iBAAiB,EAAC,MAAM,kCAAkC,CAAC;AAQnE;;;GAGG;AACH,IAAa,qBAAqB,GAAlC,MAAa,qBAAsB,SAAQ,cAA8B;IACvE,YACE,QAAyB,EACR,aAA4B,EACZ,gBAAwC,EAAE;;QAE3E,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEhB,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAC3B;YACE,WAAW,EAAE,IAAI;SAClB,EACD,CAAA,MAAA,aAAa,CAAC,OAAO,0CAAE,MAAM,KAAI,EAAE,EACnC,aAAa,CACd,CAAC;QACF,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,CAAC,QAAgB,EAAE,OAA+B;QACvD,MAAM,EAAC,IAAI,EAAE,GAAG,KAAK,EAAC,GAAG,OAAO,CAAC;QAEjC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,iBAAiB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;QAEnD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAzBY,qBAAqB;IAG7B,WAAA,aAAa,EAAE,CAAA;IACf,WAAA,MAAM,CAAC,uBAAuB,CAAC,CAAA;qCAFtB,eAAe;GAFhB,qBAAqB,CAyBjC;SAzBY,qBAAqB","sourcesContent":["import {PLATFORM_ROUTER_OPTIONS, PlatformHandler, PlatformRouter, PlatformStaticsOptions} from \"@tsed/common\";\nimport {Configuration, Inject} from \"@tsed/di\";\nimport Express from \"express\";\nimport {RouterOptions} from \"express\";\nimport {staticsMiddleware} from \"../middlewares/staticsMiddleware\";\n\ndeclare global {\n namespace TsED {\n export interface Router extends Express.Router {}\n }\n}\n\n/**\n * @platform\n * @express\n */\nexport class PlatformExpressRouter extends PlatformRouter<Express.Router> {\n constructor(\n platform: PlatformHandler,\n @Configuration() configuration: Configuration,\n @Inject(PLATFORM_ROUTER_OPTIONS) routerOptions: Partial<RouterOptions> = {}\n ) {\n super(platform);\n\n const options = Object.assign(\n {\n mergeParams: true\n },\n configuration.express?.router || {},\n routerOptions\n );\n this.rawRouter = this.raw = Express.Router(options);\n }\n\n statics(endpoint: string, options: PlatformStaticsOptions) {\n const {root, ...props} = options;\n\n this.use(endpoint, staticsMiddleware(root, props));\n\n return this;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC","sourcesContent":["export * from \"./PlatformExpressApplication\";\nexport * from \"./PlatformExpressHandler\";\nexport * from \"./PlatformExpressResponse\";\nexport * from \"./PlatformExpressRequest\";\nexport * from \"./PlatformExpressRouter\";\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { PlatformBuilder, PlatformHandler, PlatformRequest, PlatformResponse, PlatformRouter } from "@tsed/common";
|
|
2
|
+
import { Type } from "@tsed/core";
|
|
3
|
+
import Express from "express";
|
|
4
|
+
import { PlatformExpressHandler, PlatformExpressRequest, PlatformExpressResponse, PlatformExpressRouter } from "../services";
|
|
5
|
+
/**
|
|
6
|
+
* @platform
|
|
7
|
+
* @express
|
|
8
|
+
*/
|
|
9
|
+
export declare class PlatformExpress extends PlatformBuilder<Express.Application, Express.Router> {
|
|
10
|
+
static providers: ({
|
|
11
|
+
provide: typeof PlatformRouter;
|
|
12
|
+
useClass: typeof PlatformExpressRouter;
|
|
13
|
+
} | {
|
|
14
|
+
provide: typeof PlatformHandler;
|
|
15
|
+
useClass: typeof PlatformExpressHandler;
|
|
16
|
+
} | {
|
|
17
|
+
provide: typeof PlatformResponse;
|
|
18
|
+
useClass: typeof PlatformExpressResponse;
|
|
19
|
+
} | {
|
|
20
|
+
provide: typeof PlatformRequest;
|
|
21
|
+
useClass: typeof PlatformExpressRequest;
|
|
22
|
+
})[];
|
|
23
|
+
/**
|
|
24
|
+
* Create new serverless application. In this mode, the component scan are disabled.
|
|
25
|
+
* @param module
|
|
26
|
+
* @param settings
|
|
27
|
+
*/
|
|
28
|
+
static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformExpress;
|
|
29
|
+
/**
|
|
30
|
+
* Bootstrap a server application
|
|
31
|
+
* @param module
|
|
32
|
+
* @param settings
|
|
33
|
+
*/
|
|
34
|
+
static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformExpress>;
|
|
35
|
+
protected useRouter(): this;
|
|
36
|
+
protected useContext(): this;
|
|
37
|
+
protected loadRoutes(): Promise<void>;
|
|
38
|
+
private configureViewsEngine;
|
|
39
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Specify the behavior of the router controller.
|
|
3
|
+
*
|
|
4
|
+
* ```typescript
|
|
5
|
+
* @Controller("/")
|
|
6
|
+
* @CaseSensitive(true)
|
|
7
|
+
* class MyCtrl {
|
|
8
|
+
*
|
|
9
|
+
* }
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Property | Description | Default
|
|
13
|
+
* ---|---|---
|
|
14
|
+
* CaseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.
|
|
15
|
+
* MergeParams | Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child’s value take precedence. | false
|
|
16
|
+
* Strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.
|
|
17
|
+
*
|
|
18
|
+
* @param caseSensitive
|
|
19
|
+
* @returns {Function}
|
|
20
|
+
* @decorator
|
|
21
|
+
* @express
|
|
22
|
+
*/
|
|
23
|
+
export declare function CaseSensitive(caseSensitive: boolean): Function;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Specify the behavior of the router controller.
|
|
3
|
+
*
|
|
4
|
+
* ```typescript
|
|
5
|
+
* @Controller("/")
|
|
6
|
+
* @MergeParams(true)
|
|
7
|
+
* class MyCtrl {
|
|
8
|
+
*
|
|
9
|
+
* }
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Property | Description | Default
|
|
13
|
+
* ---|---|---
|
|
14
|
+
* CaseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.
|
|
15
|
+
* MergeParams | Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child’s value take precedence. | false
|
|
16
|
+
* Strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.
|
|
17
|
+
*
|
|
18
|
+
* @param mergeParams
|
|
19
|
+
* @returns {Function}
|
|
20
|
+
* @decorator
|
|
21
|
+
* @express
|
|
22
|
+
*/
|
|
23
|
+
export declare function MergeParams(mergeParams?: boolean): Function;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RouterOptions } from "express";
|
|
2
|
+
/**
|
|
3
|
+
* Specify the behavior of the router controller.
|
|
4
|
+
*
|
|
5
|
+
* ```typescript
|
|
6
|
+
* @Controller("/")
|
|
7
|
+
* @RouterSettings({mergeParams: true})
|
|
8
|
+
* class MyCtrl {
|
|
9
|
+
*
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Property | Description | Default
|
|
14
|
+
* ---|---|---
|
|
15
|
+
* caseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.
|
|
16
|
+
* mergeParams | Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child’s value take precedence. | false
|
|
17
|
+
* strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.
|
|
18
|
+
*
|
|
19
|
+
* @returns {(target:any)=>void}
|
|
20
|
+
* @decorator
|
|
21
|
+
* @param routerOptions
|
|
22
|
+
* @express
|
|
23
|
+
*/
|
|
24
|
+
export declare function RouterSettings(routerOptions: RouterOptions): Function;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Specify the behavior of the router controller.
|
|
3
|
+
*
|
|
4
|
+
* ```typescript
|
|
5
|
+
* @Controller("/")
|
|
6
|
+
* @Strict(true)
|
|
7
|
+
* class MyCtrl {
|
|
8
|
+
*
|
|
9
|
+
* }
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Property | Description | Default
|
|
13
|
+
* ---|---|---
|
|
14
|
+
* CaseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.
|
|
15
|
+
* MergeParams | Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child’s value take precedence. | false
|
|
16
|
+
* Strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.
|
|
17
|
+
*
|
|
18
|
+
* @param strict
|
|
19
|
+
* @returns {Function}
|
|
20
|
+
* @decorator
|
|
21
|
+
* @express
|
|
22
|
+
*/
|
|
23
|
+
export declare function Strict(strict: boolean): Function;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="express-serve-static-core" />
|
|
2
|
+
import { RouterOptions } from "express";
|
|
3
|
+
export interface PlatformExpressSettings {
|
|
4
|
+
/**
|
|
5
|
+
* Global configuration for the Express.Router. See express [documentation](http://expressjs.com/en/api.html#express.router).
|
|
6
|
+
*/
|
|
7
|
+
router?: RouterOptions;
|
|
8
|
+
app?: Express.Application;
|
|
9
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import Express from "express";
|
|
2
|
+
export interface PlatformExpressStaticsOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Enable or disable setting Cache-Control response header, defaults to true.
|
|
5
|
+
* Disabling this will ignore the immutable and maxAge options.
|
|
6
|
+
*/
|
|
7
|
+
cacheControl?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Set how "dotfiles" are treated when encountered. A dotfile is a file or directory that begins with a dot (".").
|
|
10
|
+
* Note this check is done on the path itself without checking if the path actually exists on the disk.
|
|
11
|
+
* If root is specified, only the dotfiles above the root are checked (i.e. the root itself can be within a dotfile when when set to "deny").
|
|
12
|
+
* The default value is 'ignore'.
|
|
13
|
+
* 'allow' No special treatment for dotfiles
|
|
14
|
+
* 'deny' Send a 403 for any request for a dotfile
|
|
15
|
+
* 'ignore' Pretend like the dotfile does not exist and call next()
|
|
16
|
+
*/
|
|
17
|
+
dotfiles?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Enable or disable etag generation, defaults to true.
|
|
20
|
+
*/
|
|
21
|
+
etag?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Set file extension fallbacks. When set, if a file is not found, the given extensions will be added to the file name and search for.
|
|
24
|
+
* The first that exists will be served. Example: ['html', 'htm'].
|
|
25
|
+
* The default value is false.
|
|
26
|
+
*/
|
|
27
|
+
extensions?: string[] | false;
|
|
28
|
+
/**
|
|
29
|
+
* Let client errors fall-through as unhandled requests, otherwise forward a client error.
|
|
30
|
+
* The default value is true.
|
|
31
|
+
*/
|
|
32
|
+
fallthrough?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Enable or disable the immutable directive in the Cache-Control response header.
|
|
35
|
+
* If enabled, the maxAge option should also be specified to enable caching. The immutable directive will prevent supported clients from making conditional requests during the life of the maxAge option to check if the file has changed.
|
|
36
|
+
*/
|
|
37
|
+
immutable?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* By default this module will send "index.html" files in response to a request on a directory.
|
|
40
|
+
* To disable this set false or to supply a new index pass a string or an array in preferred order.
|
|
41
|
+
*/
|
|
42
|
+
index?: boolean | string | string[];
|
|
43
|
+
/**
|
|
44
|
+
* Enable or disable Last-Modified header, defaults to true. Uses the file system's last modified value.
|
|
45
|
+
*/
|
|
46
|
+
lastModified?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Provide a max-age in milliseconds for http caching, defaults to 0. This can also be a string accepted by the ms module.
|
|
49
|
+
*/
|
|
50
|
+
maxAge?: number | string;
|
|
51
|
+
/**
|
|
52
|
+
* Redirect to trailing "/" when the pathname is a dir. Defaults to true.
|
|
53
|
+
*/
|
|
54
|
+
redirect?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Function to set custom headers on response. Alterations to the headers need to occur synchronously.
|
|
57
|
+
* The function is called as fn(res, path, stat), where the arguments are:
|
|
58
|
+
* res the response object
|
|
59
|
+
* path the file path that is being sent
|
|
60
|
+
* stat the stat object of the file that is being sent
|
|
61
|
+
*/
|
|
62
|
+
setHeaders?: (res: Express.Response, path: string, stat: any) => any;
|
|
63
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Express from "express";
|
|
2
|
+
import { PlatformExpressSettings } from "./PlatformExpressSettings";
|
|
3
|
+
export * from "./PlatformExpressSettings";
|
|
4
|
+
export * from "./PlatformExpressStaticsOptions";
|
|
5
|
+
declare global {
|
|
6
|
+
namespace TsED {
|
|
7
|
+
interface Configuration {
|
|
8
|
+
/**
|
|
9
|
+
* Configuration related to Express platform application.
|
|
10
|
+
*/
|
|
11
|
+
express: PlatformExpressSettings;
|
|
12
|
+
}
|
|
13
|
+
interface NextFunction extends Express.NextFunction {
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Configuration, PlatformApplication, PlatformHandler } from "@tsed/common";
|
|
2
|
+
import Express from "express";
|
|
3
|
+
import { PlatformExpressStaticsOptions } from "../interfaces/PlatformExpressStaticsOptions";
|
|
4
|
+
import { PlatformExpressRouter } from "./PlatformExpressRouter";
|
|
5
|
+
declare global {
|
|
6
|
+
namespace TsED {
|
|
7
|
+
interface Application extends Express.Application {
|
|
8
|
+
}
|
|
9
|
+
interface StaticsOptions extends PlatformExpressStaticsOptions {
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @platform
|
|
15
|
+
* @express
|
|
16
|
+
*/
|
|
17
|
+
export declare class PlatformExpressApplication extends PlatformExpressRouter implements PlatformApplication<Express.Application, Express.Router> {
|
|
18
|
+
app: Express.Application;
|
|
19
|
+
rawApp: Express.Application;
|
|
20
|
+
rawRouter: Express.Router;
|
|
21
|
+
constructor(platformHandler: PlatformHandler, configuration: Configuration);
|
|
22
|
+
getApp(): Express.Application;
|
|
23
|
+
callback(): Express.Application;
|
|
24
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HandlerMetadata, OnRequestOptions, PlatformHandler } from "@tsed/common";
|
|
2
|
+
/**
|
|
3
|
+
* @platform
|
|
4
|
+
* @express
|
|
5
|
+
*/
|
|
6
|
+
export declare class PlatformExpressHandler extends PlatformHandler {
|
|
7
|
+
protected createRawHandler(metadata: HandlerMetadata): Function;
|
|
8
|
+
protected onCtxRequest(requestOptions: OnRequestOptions): Promise<any>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PlatformContext, PlatformRequest } from "@tsed/common";
|
|
2
|
+
import type Express from "express";
|
|
3
|
+
declare module "express" {
|
|
4
|
+
interface Request {
|
|
5
|
+
id: string;
|
|
6
|
+
$ctx: PlatformContext;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
declare global {
|
|
10
|
+
namespace TsED {
|
|
11
|
+
interface Request extends Express.Request {
|
|
12
|
+
id: string;
|
|
13
|
+
$ctx: PlatformContext;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @platform
|
|
19
|
+
* @express
|
|
20
|
+
*/
|
|
21
|
+
export declare class PlatformExpressRequest extends PlatformRequest<Express.Request> {
|
|
22
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PlatformResponse } from "@tsed/common";
|
|
2
|
+
import type Express from "express";
|
|
3
|
+
declare global {
|
|
4
|
+
namespace TsED {
|
|
5
|
+
interface Response extends Express.Response {
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @platform
|
|
11
|
+
* @express
|
|
12
|
+
*/
|
|
13
|
+
export declare class PlatformExpressResponse extends PlatformResponse<Express.Response> {
|
|
14
|
+
}
|