@tsed/platform-express 6.88.1 → 6.92.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.
Files changed (133) hide show
  1. package/lib/{components → cjs/components}/PlatformExpress.d.ts +12 -9
  2. package/lib/cjs/components/PlatformExpress.js +141 -0
  3. package/lib/cjs/components/PlatformExpress.js.map +1 -0
  4. package/lib/{decorators → cjs/decorators}/caseSensitive.d.ts +0 -0
  5. package/lib/{decorators → cjs/decorators}/caseSensitive.js +1 -1
  6. package/lib/cjs/decorators/caseSensitive.js.map +1 -0
  7. package/lib/{decorators → cjs/decorators}/index.d.ts +0 -0
  8. package/lib/cjs/decorators/index.js +8 -0
  9. package/lib/cjs/decorators/index.js.map +1 -0
  10. package/lib/{decorators → cjs/decorators}/mergeParams.d.ts +0 -0
  11. package/lib/{decorators → cjs/decorators}/mergeParams.js +1 -1
  12. package/lib/cjs/decorators/mergeParams.js.map +1 -0
  13. package/lib/{decorators → cjs/decorators}/routerSettings.d.ts +0 -0
  14. package/lib/{decorators → cjs/decorators}/routerSettings.js +1 -1
  15. package/lib/cjs/decorators/routerSettings.js.map +1 -0
  16. package/lib/{decorators → cjs/decorators}/strict.d.ts +0 -0
  17. package/lib/{decorators → cjs/decorators}/strict.js +1 -1
  18. package/lib/cjs/decorators/strict.js.map +1 -0
  19. package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
  20. package/lib/cjs/index.js +16 -0
  21. package/lib/cjs/index.js.map +1 -0
  22. package/lib/{interfaces → cjs/interfaces}/PlatformExpressSettings.d.ts +0 -0
  23. package/lib/{interfaces → cjs/interfaces}/PlatformExpressSettings.js +0 -0
  24. package/lib/cjs/interfaces/PlatformExpressSettings.js.map +1 -0
  25. package/lib/{interfaces → cjs/interfaces}/PlatformExpressStaticsOptions.d.ts +0 -0
  26. package/lib/{interfaces → cjs/interfaces}/PlatformExpressStaticsOptions.js +0 -0
  27. package/lib/cjs/interfaces/PlatformExpressStaticsOptions.js.map +1 -0
  28. package/lib/{interfaces → cjs/interfaces}/index.d.ts +0 -0
  29. package/lib/cjs/interfaces/index.js +6 -0
  30. package/lib/cjs/interfaces/index.js.map +1 -0
  31. package/lib/{middlewares → cjs/middlewares}/rawBodyMiddleware.d.ts +0 -0
  32. package/lib/{middlewares → cjs/middlewares}/rawBodyMiddleware.js +1 -1
  33. package/lib/cjs/middlewares/rawBodyMiddleware.js.map +1 -0
  34. package/lib/{middlewares → cjs/middlewares}/staticsMiddleware.d.ts +0 -0
  35. package/lib/{middlewares → cjs/middlewares}/staticsMiddleware.js +1 -1
  36. package/lib/cjs/middlewares/staticsMiddleware.js.map +1 -0
  37. package/lib/{services → cjs/services}/PlatformExpressApplication.d.ts +0 -0
  38. package/lib/{services → cjs/services}/PlatformExpressApplication.js +6 -5
  39. package/lib/cjs/services/PlatformExpressApplication.js.map +1 -0
  40. package/lib/{services → cjs/services}/PlatformExpressHandler.d.ts +0 -0
  41. package/lib/{services → cjs/services}/PlatformExpressHandler.js +0 -0
  42. package/lib/cjs/services/PlatformExpressHandler.js.map +1 -0
  43. package/lib/{services → cjs/services}/PlatformExpressRequest.d.ts +0 -0
  44. package/lib/{services → cjs/services}/PlatformExpressRequest.js +0 -0
  45. package/lib/cjs/services/PlatformExpressRequest.js.map +1 -0
  46. package/lib/{services → cjs/services}/PlatformExpressResponse.d.ts +0 -0
  47. package/lib/{services → cjs/services}/PlatformExpressResponse.js +0 -0
  48. package/lib/cjs/services/PlatformExpressResponse.js.map +1 -0
  49. package/lib/{services → cjs/services}/PlatformExpressRouter.d.ts +0 -0
  50. package/lib/{services → cjs/services}/PlatformExpressRouter.js +6 -6
  51. package/lib/cjs/services/PlatformExpressRouter.js.map +1 -0
  52. package/lib/{services → cjs/services}/index.d.ts +0 -0
  53. package/lib/cjs/services/index.js +9 -0
  54. package/lib/cjs/services/index.js.map +1 -0
  55. package/lib/esm/components/PlatformExpress.js +118 -0
  56. package/lib/esm/components/PlatformExpress.js.map +1 -0
  57. package/lib/esm/decorators/caseSensitive.js +27 -0
  58. package/lib/esm/decorators/caseSensitive.js.map +1 -0
  59. package/lib/esm/decorators/index.js +5 -0
  60. package/lib/esm/decorators/index.js.map +1 -0
  61. package/lib/esm/decorators/mergeParams.js +27 -0
  62. package/lib/esm/decorators/mergeParams.js.map +1 -0
  63. package/lib/esm/decorators/routerSettings.js +28 -0
  64. package/lib/esm/decorators/routerSettings.js.map +1 -0
  65. package/lib/esm/decorators/strict.js +27 -0
  66. package/lib/esm/decorators/strict.js.map +1 -0
  67. package/lib/esm/index.js +13 -0
  68. package/lib/esm/index.js.map +1 -0
  69. package/lib/esm/interfaces/PlatformExpressSettings.js +2 -0
  70. package/lib/esm/interfaces/PlatformExpressSettings.js.map +1 -0
  71. package/lib/esm/interfaces/PlatformExpressStaticsOptions.js +2 -0
  72. package/lib/esm/interfaces/PlatformExpressStaticsOptions.js.map +1 -0
  73. package/lib/esm/interfaces/index.js +3 -0
  74. package/lib/esm/interfaces/index.js.map +1 -0
  75. package/lib/esm/middlewares/rawBodyMiddleware.js +22 -0
  76. package/lib/esm/middlewares/rawBodyMiddleware.js.map +1 -0
  77. package/lib/esm/middlewares/staticsMiddleware.js +16 -0
  78. package/lib/esm/middlewares/staticsMiddleware.js.map +1 -0
  79. package/lib/esm/services/PlatformExpressApplication.js +29 -0
  80. package/lib/esm/services/PlatformExpressApplication.js.map +1 -0
  81. package/lib/esm/services/PlatformExpressHandler.js +27 -0
  82. package/lib/esm/services/PlatformExpressHandler.js.map +1 -0
  83. package/lib/esm/services/PlatformExpressRequest.js +8 -0
  84. package/lib/esm/services/PlatformExpressRequest.js.map +1 -0
  85. package/lib/esm/services/PlatformExpressResponse.js +8 -0
  86. package/lib/esm/services/PlatformExpressResponse.js.map +1 -0
  87. package/lib/esm/services/PlatformExpressRouter.js +31 -0
  88. package/lib/esm/services/PlatformExpressRouter.js.map +1 -0
  89. package/lib/esm/services/index.js +6 -0
  90. package/lib/esm/services/index.js.map +1 -0
  91. package/lib/types/components/PlatformExpress.d.ts +42 -0
  92. package/lib/types/decorators/caseSensitive.d.ts +23 -0
  93. package/lib/types/decorators/index.d.ts +4 -0
  94. package/lib/types/decorators/mergeParams.d.ts +23 -0
  95. package/lib/types/decorators/routerSettings.d.ts +24 -0
  96. package/lib/types/decorators/strict.d.ts +23 -0
  97. package/lib/types/index.d.ts +4 -0
  98. package/lib/types/interfaces/PlatformExpressSettings.d.ts +9 -0
  99. package/lib/types/interfaces/PlatformExpressStaticsOptions.d.ts +63 -0
  100. package/lib/types/interfaces/index.d.ts +16 -0
  101. package/lib/types/middlewares/rawBodyMiddleware.d.ts +4 -0
  102. package/lib/types/middlewares/staticsMiddleware.d.ts +4 -0
  103. package/lib/types/services/PlatformExpressApplication.d.ts +24 -0
  104. package/lib/types/services/PlatformExpressHandler.d.ts +9 -0
  105. package/lib/types/services/PlatformExpressRequest.d.ts +22 -0
  106. package/lib/types/services/PlatformExpressResponse.d.ts +14 -0
  107. package/lib/types/services/PlatformExpressRouter.d.ts +18 -0
  108. package/lib/types/services/index.d.ts +5 -0
  109. package/package.json +27 -19
  110. package/tsconfig.compile.esm.json +23 -0
  111. package/lib/components/PlatformExpress.js +0 -131
  112. package/lib/components/PlatformExpress.js.map +0 -1
  113. package/lib/decorators/caseSensitive.js.map +0 -1
  114. package/lib/decorators/index.js +0 -8
  115. package/lib/decorators/index.js.map +0 -1
  116. package/lib/decorators/mergeParams.js.map +0 -1
  117. package/lib/decorators/routerSettings.js.map +0 -1
  118. package/lib/decorators/strict.js.map +0 -1
  119. package/lib/index.js +0 -16
  120. package/lib/index.js.map +0 -1
  121. package/lib/interfaces/PlatformExpressSettings.js.map +0 -1
  122. package/lib/interfaces/PlatformExpressStaticsOptions.js.map +0 -1
  123. package/lib/interfaces/index.js +0 -6
  124. package/lib/interfaces/index.js.map +0 -1
  125. package/lib/middlewares/rawBodyMiddleware.js.map +0 -1
  126. package/lib/middlewares/staticsMiddleware.js.map +0 -1
  127. package/lib/services/PlatformExpressApplication.js.map +0 -1
  128. package/lib/services/PlatformExpressHandler.js.map +0 -1
  129. package/lib/services/PlatformExpressRequest.js.map +0 -1
  130. package/lib/services/PlatformExpressResponse.js.map +0 -1
  131. package/lib/services/PlatformExpressRouter.js.map +0 -1
  132. package/lib/services/index.js +0 -9
  133. package/lib/services/index.js.map +0 -1
@@ -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,4 @@
1
+ export * from "./interfaces";
2
+ export * from "./decorators";
3
+ export * from "./services";
4
+ export * from "./components/PlatformExpress";
@@ -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,4 @@
1
+ import { Request } from "express";
2
+ export declare function rawBodyMiddleware(request: Request & {
3
+ rawBody: string;
4
+ }, response: any, next: any): void;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @ignore
3
+ */
4
+ export declare function staticsMiddleware(directory: string, options?: any): (request: any, response: any, next: any) => void;
@@ -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
+ }
@@ -0,0 +1,18 @@
1
+ import { PlatformHandler, PlatformRouter, PlatformStaticsOptions } from "@tsed/common";
2
+ import { Configuration } from "@tsed/di";
3
+ import Express from "express";
4
+ import { RouterOptions } from "express";
5
+ declare global {
6
+ namespace TsED {
7
+ interface Router extends Express.Router {
8
+ }
9
+ }
10
+ }
11
+ /**
12
+ * @platform
13
+ * @express
14
+ */
15
+ export declare class PlatformExpressRouter extends PlatformRouter<Express.Router> {
16
+ constructor(platform: PlatformHandler, configuration: Configuration, routerOptions?: Partial<RouterOptions>);
17
+ statics(endpoint: string, options: PlatformStaticsOptions): this;
18
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./PlatformExpressApplication";
2
+ export * from "./PlatformExpressHandler";
3
+ export * from "./PlatformExpressResponse";
4
+ export * from "./PlatformExpressRequest";
5
+ export * from "./PlatformExpressRouter";
package/package.json CHANGED
@@ -1,11 +1,24 @@
1
1
  {
2
2
  "name": "@tsed/platform-express",
3
- "version": "6.88.1",
3
+ "version": "6.92.0",
4
4
  "description": "A TypeScript Framework on top of Express",
5
- "source": "./src/index.ts",
6
- "main": "./lib/index.js",
7
- "typings": "./lib/index.d.ts",
8
5
  "private": false,
6
+ "source": "./src/index.ts",
7
+ "main": "./lib/cjs/index.js",
8
+ "typings": "./lib/types/index.d.ts",
9
+ "exports": {
10
+ "types": "./lib/types/index.d.ts",
11
+ "import": "./lib/esm/index.js",
12
+ "require": "./lib/cjs/index.js",
13
+ "default": "./lib/esm/index.js"
14
+ },
15
+ "scripts": {
16
+ "build": "yarn run build:esm && yarn run build:cjs",
17
+ "build:cjs": "tsc --build tsconfig.compile.json",
18
+ "build:esm": "tsc --build tsconfig.compile.esm.json",
19
+ "start": "ts-node -r tsconfig-paths/register test/app/index.ts",
20
+ "start:emulate": "ts-node -r tsconfig-paths/register test/app/emulate.ts"
21
+ },
9
22
  "keywords": [
10
23
  "Express",
11
24
  "TypeScript",
@@ -35,21 +48,16 @@
35
48
  },
36
49
  "homepage": "https://github.com/tsedio/tsed/tree/production/packages/platform/platform-express",
37
50
  "repository": "https://github.com/tsedio/tsed",
38
- "scripts": {
39
- "build": "tsc --build tsconfig.compile.json",
40
- "start": "ts-node -r tsconfig-paths/register test/app/index.ts",
41
- "start:emulate": "ts-node -r tsconfig-paths/register test/app/emulate.ts"
42
- },
43
51
  "dependencies": {
44
52
  "express": "^4.17.1",
45
53
  "multer": "^1.4.2",
46
54
  "tslib": "2.2.0"
47
55
  },
48
56
  "devDependencies": {
49
- "@tsed/common": "6.88.1",
50
- "@tsed/core": "6.88.1",
51
- "@tsed/di": "6.88.1",
52
- "@tsed/platform-test-utils": "6.88.1",
57
+ "@tsed/common": "6.92.0",
58
+ "@tsed/core": "6.92.0",
59
+ "@tsed/di": "6.92.0",
60
+ "@tsed/platform-test-utils": "6.92.0",
53
61
  "@types/body-parser": "1.19.0",
54
62
  "@types/compression": "1.7.0",
55
63
  "@types/cookie-parser": "1.4.2",
@@ -65,13 +73,13 @@
65
73
  "method-override": "3.0.0"
66
74
  },
67
75
  "peerDependencies": {
68
- "@tsed/common": "^6.88.1",
69
- "@tsed/core": "^6.88.1",
70
- "@tsed/di": "^6.88.1",
71
- "@tsed/json-mapper": "^6.88.1",
76
+ "@tsed/common": "^6.92.0",
77
+ "@tsed/core": "^6.92.0",
78
+ "@tsed/di": "^6.92.0",
79
+ "@tsed/json-mapper": "^6.92.0",
72
80
  "@tsed/logger": ">=6.0.0",
73
- "@tsed/openspec": "^6.88.1",
74
- "@tsed/schema": "^6.88.1",
81
+ "@tsed/openspec": "^6.92.0",
82
+ "@tsed/schema": "^6.92.0",
75
83
  "@types/multer": "^1.4.5",
76
84
  "body-parser": "1.19.0"
77
85
  }
@@ -0,0 +1,23 @@
1
+ {
2
+ "extends": "./tsconfig.compile.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "module": "ES2020",
6
+ "rootDir": "src",
7
+ "outDir": "./lib/esm",
8
+ "declaration": true,
9
+ "declarationDir": "./lib/types"
10
+ },
11
+ "exclude": [
12
+ "node_modules",
13
+ "test",
14
+ "lib",
15
+ "benchmark",
16
+ "coverage",
17
+ "spec",
18
+ "**/*.benchmark.ts",
19
+ "**/*.spec.ts",
20
+ "keys",
21
+ "jest.config.js"
22
+ ]
23
+ }
@@ -1,131 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.PlatformExpress = void 0;
23
- const common_1 = require("@tsed/common");
24
- const core_1 = require("@tsed/core");
25
- const rawBodyMiddleware_1 = require("../middlewares/rawBodyMiddleware");
26
- const services_1 = require("../services");
27
- /**
28
- * @platform
29
- * @express
30
- */
31
- class PlatformExpress extends common_1.PlatformBuilder {
32
- /**
33
- * Create new serverless application. In this mode, the component scan are disabled.
34
- * @param module
35
- * @param settings
36
- */
37
- static create(module, settings = {}) {
38
- return this.build(PlatformExpress, module, {
39
- httpsPort: false,
40
- httpPort: false,
41
- ...settings,
42
- disableComponentsScan: true
43
- });
44
- }
45
- /**
46
- * Bootstrap a server application
47
- * @param module
48
- * @param settings
49
- */
50
- static async bootstrap(module, settings = {}) {
51
- return this.build(PlatformExpress, module, settings).bootstrap();
52
- }
53
- useRouter() {
54
- this.logger.debug("Mount app router");
55
- this.app.getApp().use(rawBodyMiddleware_1.rawBodyMiddleware);
56
- this.app.getApp().use(this.app.getRouter());
57
- return this;
58
- }
59
- useContext() {
60
- this.logger.debug("Mount app context");
61
- const invoke = common_1.createContext(this.injector);
62
- this.app.getApp().use(async (request, response, next) => {
63
- await invoke({ request, response });
64
- return next();
65
- });
66
- return this;
67
- }
68
- async loadRoutes() {
69
- // disable x-powered-by header
70
- this.injector.settings.get("env") === core_1.Env.PROD && this.app.getApp().disable("x-powered-by");
71
- await this.configureViewsEngine();
72
- await super.loadRoutes();
73
- // NOT FOUND
74
- this.app.use((req, res, next) => {
75
- var _a;
76
- !res.headersSent && ((_a = this.injector.get(common_1.PlatformExceptions)) === null || _a === void 0 ? void 0 : _a.resourceNotFound(req.$ctx));
77
- });
78
- // EXCEPTION FILTERS
79
- this.app.use((err, req, res, next) => {
80
- var _a;
81
- !res.headersSent && ((_a = this.injector.get(common_1.PlatformExceptions)) === null || _a === void 0 ? void 0 : _a.catch(err, req.$ctx));
82
- });
83
- }
84
- async configureViewsEngine() {
85
- try {
86
- const { exists, disabled } = this.settings.get("views") || {};
87
- if (exists && !disabled) {
88
- const { PlatformViews } = await Promise.resolve().then(() => __importStar(require("@tsed/platform-views")));
89
- const platformViews = this.injector.get(PlatformViews);
90
- const app = this.app.getApp();
91
- platformViews.getEngines().forEach(({ extension, engine }) => {
92
- app.engine(extension, engine.render);
93
- });
94
- platformViews.viewEngine && this.app.getApp().set("view engine", platformViews.viewEngine);
95
- platformViews.root && this.app.getApp().set("views", platformViews.root);
96
- }
97
- }
98
- catch (error) {
99
- // istanbul ignore next
100
- this.injector.logger.warn({
101
- event: "PLATFORM_VIEWS_ERROR",
102
- message: "Unable to configure the PlatformViews service on your environment.",
103
- error
104
- });
105
- }
106
- }
107
- }
108
- exports.PlatformExpress = PlatformExpress;
109
- PlatformExpress.providers = [
110
- {
111
- provide: common_1.PlatformApplication,
112
- useClass: services_1.PlatformExpressApplication
113
- },
114
- {
115
- provide: common_1.PlatformRouter,
116
- useClass: services_1.PlatformExpressRouter
117
- },
118
- {
119
- provide: common_1.PlatformHandler,
120
- useClass: services_1.PlatformExpressHandler
121
- },
122
- {
123
- provide: common_1.PlatformResponse,
124
- useClass: services_1.PlatformExpressResponse
125
- },
126
- {
127
- provide: common_1.PlatformRequest,
128
- useClass: services_1.PlatformExpressRequest
129
- }
130
- ];
131
- //# sourceMappingURL=PlatformExpress.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformExpress.js","sourceRoot":"","sources":["../../src/components/PlatformExpress.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n createContext,\n PlatformApplication,\n PlatformBuilder,\n PlatformExceptions,\n PlatformHandler,\n PlatformRequest,\n PlatformResponse,\n PlatformRouter\n} from \"@tsed/common\";\nimport {Env, Type} from \"@tsed/core\";\nimport Express from \"express\";\nimport {rawBodyMiddleware} from \"../middlewares/rawBodyMiddleware\";\nimport {\n PlatformExpressApplication,\n PlatformExpressHandler,\n PlatformExpressRequest,\n PlatformExpressResponse,\n PlatformExpressRouter\n} from \"../services\";\nimport type {PlatformViews} from \"@tsed/platform-views\";\n\n/**\n * @platform\n * @express\n */\nexport class PlatformExpress extends PlatformBuilder<Express.Application, Express.Router> {\n static providers = [\n {\n provide: PlatformApplication,\n useClass: PlatformExpressApplication\n },\n {\n provide: PlatformRouter,\n useClass: PlatformExpressRouter\n },\n {\n provide: PlatformHandler,\n useClass: PlatformExpressHandler\n },\n {\n provide: PlatformResponse,\n useClass: PlatformExpressResponse\n },\n {\n provide: PlatformRequest,\n useClass: PlatformExpressRequest\n }\n ];\n\n /**\n * Create new serverless application. In this mode, the component scan are disabled.\n * @param module\n * @param settings\n */\n static create(module: Type<any>, settings: Partial<TsED.Configuration> = {}) {\n return this.build<PlatformExpress>(PlatformExpress, module, {\n httpsPort: false,\n httpPort: false,\n ...settings,\n disableComponentsScan: true\n });\n }\n\n /**\n * Bootstrap a server application\n * @param module\n * @param settings\n */\n static async bootstrap(module: Type<any>, settings: Partial<TsED.Configuration> = {}): Promise<PlatformExpress> {\n return this.build<PlatformExpress>(PlatformExpress, module, settings).bootstrap();\n }\n\n protected useRouter(): this {\n this.logger.debug(\"Mount app router\");\n this.app.getApp().use(rawBodyMiddleware);\n this.app.getApp().use(this.app.getRouter());\n\n return this;\n }\n\n protected useContext(): this {\n this.logger.debug(\"Mount app context\");\n\n const invoke = createContext(this.injector);\n\n this.app.getApp().use(async (request: any, response: any, next: any) => {\n await invoke({request, response});\n\n return next();\n });\n\n return this;\n }\n\n protected async loadRoutes(): Promise<void> {\n // disable x-powered-by header\n this.injector.settings.get(\"env\") === Env.PROD && this.app.getApp().disable(\"x-powered-by\");\n\n await this.configureViewsEngine();\n\n await super.loadRoutes();\n\n // NOT FOUND\n this.app.use((req: any, res: any, next: any) => {\n !res.headersSent && this.injector.get<PlatformExceptions>(PlatformExceptions)?.resourceNotFound(req.$ctx);\n });\n\n // EXCEPTION FILTERS\n this.app.use((err: any, req: any, res: any, next: any) => {\n !res.headersSent && this.injector.get<PlatformExceptions>(PlatformExceptions)?.catch(err, req.$ctx);\n });\n }\n\n private async configureViewsEngine() {\n try {\n const {exists, disabled} = this.settings.get(\"views\") || {};\n\n if (exists && !disabled) {\n const {PlatformViews} = await import(\"@tsed/platform-views\");\n const platformViews = this.injector.get<PlatformViews>(PlatformViews)!;\n const app = this.app.getApp();\n\n platformViews.getEngines().forEach(({extension, engine}) => {\n app.engine(extension, engine.render);\n });\n\n platformViews.viewEngine && this.app.getApp().set(\"view engine\", platformViews.viewEngine);\n platformViews.root && this.app.getApp().set(\"views\", platformViews.root);\n }\n } catch (error) {\n // istanbul ignore next\n this.injector.logger.warn({\n event: \"PLATFORM_VIEWS_ERROR\",\n message: \"Unable to configure the PlatformViews service on your environment.\",\n error\n });\n }\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"caseSensitive.js","sourceRoot":"","sources":["../../src/decorators/caseSensitive.ts"],"names":[],"mappings":";;;AAAA,qDAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,aAAa,CAAC,aAAsB;IAClD,OAAO,+BAAc,CAAC,EAAC,aAAa,EAAC,CAAC,CAAC;AACzC,CAAC;AAFD,sCAEC","sourcesContent":["import {RouterSettings} from \"./routerSettings\";\n\n/**\n * Specify the behavior of the router controller.\n *\n * ```typescript\n * @Controller(\"/\")\n * @CaseSensitive(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 caseSensitive\n * @returns {Function}\n * @decorator\n * @express\n */\nexport function CaseSensitive(caseSensitive: boolean) {\n return RouterSettings({caseSensitive});\n}\n"]}
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./routerSettings"), exports);
5
- tslib_1.__exportStar(require("./caseSensitive"), exports);
6
- tslib_1.__exportStar(require("./mergeParams"), exports);
7
- tslib_1.__exportStar(require("./strict"), exports);
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,0DAAgC;AAChC,wDAA8B;AAC9B,mDAAyB","sourcesContent":["export * from \"./routerSettings\";\nexport * from \"./caseSensitive\";\nexport * from \"./mergeParams\";\nexport * from \"./strict\";\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mergeParams.js","sourceRoot":"","sources":["../../src/decorators/mergeParams.ts"],"names":[],"mappings":";;;AAAA,qDAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,WAAW,CAAC,cAAuB,IAAI;IACrD,OAAO,+BAAc,CAAC,EAAC,WAAW,EAAC,CAAC,CAAC;AACvC,CAAC;AAFD,kCAEC","sourcesContent":["import {RouterSettings} from \"./routerSettings\";\n\n/**\n * Specify the behavior of the router controller.\n *\n * ```typescript\n * @Controller(\"/\")\n * @MergeParams(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 mergeParams\n * @returns {Function}\n * @decorator\n * @express\n */\nexport function MergeParams(mergeParams: boolean = true) {\n return RouterSettings({mergeParams});\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"routerSettings.js","sourceRoot":"","sources":["../../src/decorators/routerSettings.ts"],"names":[],"mappings":";;;AAAA,yCAA4C;AAC5C,qCAAsC;AAGtC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,cAAc,CAAC,aAA4B;IACzD,OAAO,iBAAU,CAAC,uBAAc,EAAE,aAAa,CAAC,CAAC;AACnD,CAAC;AAFD,wCAEC","sourcesContent":["import {ROUTER_OPTIONS} from \"@tsed/common\";\nimport {StoreMerge} from \"@tsed/core\";\nimport {RouterOptions} from \"express\";\n\n/**\n * Specify the behavior of the router controller.\n *\n * ```typescript\n * @Controller(\"/\")\n * @RouterSettings({mergeParams: 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 * @returns {(target:any)=>void}\n * @decorator\n * @param routerOptions\n * @express\n */\nexport function RouterSettings(routerOptions: RouterOptions): Function {\n return StoreMerge(ROUTER_OPTIONS, routerOptions);\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"strict.js","sourceRoot":"","sources":["../../src/decorators/strict.ts"],"names":[],"mappings":";;;AAAA,qDAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,MAAM,CAAC,MAAe;IACpC,OAAO,+BAAc,CAAC,EAAC,MAAM,EAAC,CAAC,CAAC;AAClC,CAAC;AAFD,wBAEC","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/index.js DELETED
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const common_1 = require("@tsed/common");
5
- const PlatformExpress_1 = require("./components/PlatformExpress");
6
- common_1.PlatformTest.platformBuilder = PlatformExpress_1.PlatformExpress;
7
- common_1.PlatformBuilder.currentPlatform = PlatformExpress_1.PlatformExpress;
8
- // interfaces
9
- tslib_1.__exportStar(require("./interfaces"), exports);
10
- // decorators
11
- tslib_1.__exportStar(require("./decorators"), exports);
12
- // services
13
- tslib_1.__exportStar(require("./services"), exports);
14
- // components
15
- tslib_1.__exportStar(require("./components/PlatformExpress"), exports);
16
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAA2D;AAE3D,kEAA6D;AAE7D,qBAAY,CAAC,eAAe,GAAG,iCAAe,CAAC;AAC/C,wBAAe,CAAC,eAAe,GAAG,iCAAsB,CAAC;AAEzD,aAAa;AACb,uDAA6B;AAE7B,aAAa;AACb,uDAA6B;AAE7B,WAAW;AACX,qDAA2B;AAE3B,aAAa;AACb,uEAA6C","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"]}
@@ -1 +0,0 @@
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"]}
@@ -1 +0,0 @@
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"]}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./PlatformExpressSettings"), exports);
5
- tslib_1.__exportStar(require("./PlatformExpressStaticsOptions"), exports);
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;AAGA,oEAA0C;AAC1C,0EAAgD","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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"rawBodyMiddleware.js","sourceRoot":"","sources":["../../src/middlewares/rawBodyMiddleware.ts"],"names":[],"mappings":";;;;AACA,0DAA0B;AAE1B,MAAM,KAAK,GAAG,eAAK,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,SAAgB,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;AAbD,8CAaC","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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"staticsMiddleware.js","sourceRoot":"","sources":["../../src/middlewares/staticsMiddleware.ts"],"names":[],"mappings":";;;;AAAA,8DAA8B;AAE9B;;GAEG;AACH,SAAgB,iBAAiB,CAAC,SAAiB,EAAE,UAAe,EAAE;IACpE,MAAM,UAAU,GAAG,iBAAO,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;AAVD,8CAUC","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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformExpressApplication.js","sourceRoot":"","sources":["../../src/services/PlatformExpressApplication.ts"],"names":[],"mappings":";;;;AAAA,yCAAwG;AACxG,8DAA8B;AAE9B,mEAA8D;AAU9D;;;GAGG;AACH,IAAa,0BAA0B,GAAvC,MAAa,0BAA2B,SAAQ,6CAAqB;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,iBAAO,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,mBAAA,eAAM,EAAE,CAAA,EAAoC,mBAAA,sBAAa,EAAE,CAAA;6CAAjC,wBAAe;GAL3C,0BAA0B,CAoBtC;AApBY,gEAA0B","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"]}