@tsed/platform-express 7.0.0-alpha.1 → 7.0.0-beta.10

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 (110) hide show
  1. package/lib/cjs/components/PlatformExpress.js +200 -0
  2. package/lib/cjs/components/PlatformExpress.js.map +1 -0
  3. package/lib/{decorators → cjs/decorators}/caseSensitive.js +1 -1
  4. package/lib/cjs/decorators/caseSensitive.js.map +1 -0
  5. package/lib/{decorators → cjs/decorators}/mergeParams.js +1 -1
  6. package/lib/cjs/decorators/mergeParams.js.map +1 -0
  7. package/lib/{decorators → cjs/decorators}/routerSettings.js +1 -1
  8. package/lib/cjs/decorators/routerSettings.js.map +1 -0
  9. package/lib/{decorators → cjs/decorators}/strict.js +1 -1
  10. package/lib/cjs/decorators/strict.js.map +1 -0
  11. package/lib/cjs/exports.js +7 -0
  12. package/lib/cjs/exports.js.map +1 -0
  13. package/lib/cjs/index.js +20 -0
  14. package/lib/cjs/index.js.map +1 -0
  15. package/lib/{interfaces → cjs/interfaces}/PlatformExpressSettings.js +0 -0
  16. package/lib/cjs/interfaces/PlatformExpressSettings.js.map +1 -0
  17. package/lib/{interfaces → cjs/interfaces}/PlatformExpressStaticsOptions.js +0 -0
  18. package/lib/cjs/interfaces/PlatformExpressStaticsOptions.js.map +1 -0
  19. package/lib/cjs/interfaces/interfaces.js +3 -0
  20. package/lib/cjs/interfaces/interfaces.js.map +1 -0
  21. package/lib/{middlewares → cjs/middlewares}/staticsMiddleware.js +0 -0
  22. package/lib/cjs/middlewares/staticsMiddleware.js.map +1 -0
  23. package/lib/cjs/package.json +3 -0
  24. package/lib/{services → cjs/services}/PlatformExpressHandler.js +0 -0
  25. package/lib/cjs/services/PlatformExpressHandler.js.map +1 -0
  26. package/lib/{services → cjs/services}/PlatformExpressRequest.js +0 -0
  27. package/lib/cjs/services/PlatformExpressRequest.js.map +1 -0
  28. package/lib/{services → cjs/services}/PlatformExpressResponse.js +0 -0
  29. package/lib/cjs/services/PlatformExpressResponse.js.map +1 -0
  30. package/lib/esm/components/PlatformExpress.js +196 -0
  31. package/lib/esm/components/PlatformExpress.js.map +1 -0
  32. package/lib/esm/decorators/caseSensitive.js +27 -0
  33. package/lib/esm/decorators/caseSensitive.js.map +1 -0
  34. package/lib/esm/decorators/mergeParams.js +27 -0
  35. package/lib/esm/decorators/mergeParams.js.map +1 -0
  36. package/lib/esm/decorators/routerSettings.js +28 -0
  37. package/lib/esm/decorators/routerSettings.js.map +1 -0
  38. package/lib/esm/decorators/strict.js +27 -0
  39. package/lib/esm/decorators/strict.js.map +1 -0
  40. package/lib/esm/exports.js +5 -0
  41. package/lib/esm/exports.js.map +1 -0
  42. package/lib/esm/index.js +17 -0
  43. package/lib/esm/index.js.map +1 -0
  44. package/lib/esm/interfaces/PlatformExpressSettings.js +2 -0
  45. package/lib/esm/interfaces/PlatformExpressSettings.js.map +1 -0
  46. package/lib/esm/interfaces/PlatformExpressStaticsOptions.js +2 -0
  47. package/lib/esm/interfaces/PlatformExpressStaticsOptions.js.map +1 -0
  48. package/lib/esm/interfaces/interfaces.js +2 -0
  49. package/lib/esm/interfaces/interfaces.js.map +1 -0
  50. package/lib/esm/middlewares/staticsMiddleware.js +16 -0
  51. package/lib/esm/middlewares/staticsMiddleware.js.map +1 -0
  52. package/lib/esm/package.json +3 -0
  53. package/lib/esm/services/PlatformExpressHandler.js +27 -0
  54. package/lib/esm/services/PlatformExpressHandler.js.map +1 -0
  55. package/lib/esm/services/PlatformExpressRequest.js +8 -0
  56. package/lib/esm/services/PlatformExpressRequest.js.map +1 -0
  57. package/lib/esm/services/PlatformExpressResponse.js +8 -0
  58. package/lib/esm/services/PlatformExpressResponse.js.map +1 -0
  59. package/lib/types/components/PlatformExpress.d.ts +75 -0
  60. package/lib/{decorators → types/decorators}/caseSensitive.d.ts +0 -0
  61. package/lib/{decorators → types/decorators}/mergeParams.d.ts +0 -0
  62. package/lib/{decorators → types/decorators}/routerSettings.d.ts +0 -0
  63. package/lib/{decorators → types/decorators}/strict.d.ts +0 -0
  64. package/lib/types/exports.d.ts +1 -0
  65. package/lib/types/index.d.ts +16 -0
  66. package/lib/types/interfaces/PlatformExpressSettings.d.ts +23 -0
  67. package/lib/{interfaces → types/interfaces}/PlatformExpressStaticsOptions.d.ts +0 -0
  68. package/lib/{interfaces/index.d.ts → types/interfaces/interfaces.d.ts} +0 -2
  69. package/lib/{middlewares → types/middlewares}/staticsMiddleware.d.ts +0 -0
  70. package/lib/{services → types/services}/PlatformExpressHandler.d.ts +0 -0
  71. package/lib/types/services/PlatformExpressRequest.d.ts +8 -0
  72. package/lib/{services → types/services}/PlatformExpressResponse.d.ts +0 -0
  73. package/package.json +67 -28
  74. package/readme.md +0 -2
  75. package/tsconfig.compile.esm.json +12 -0
  76. package/lib/components/PlatformExpress.d.ts +0 -28
  77. package/lib/components/PlatformExpress.js +0 -79
  78. package/lib/components/PlatformExpress.js.map +0 -1
  79. package/lib/decorators/caseSensitive.js.map +0 -1
  80. package/lib/decorators/index.d.ts +0 -4
  81. package/lib/decorators/index.js +0 -8
  82. package/lib/decorators/index.js.map +0 -1
  83. package/lib/decorators/mergeParams.js.map +0 -1
  84. package/lib/decorators/routerSettings.js.map +0 -1
  85. package/lib/decorators/strict.js.map +0 -1
  86. package/lib/index.d.ts +0 -4
  87. package/lib/index.js +0 -16
  88. package/lib/index.js.map +0 -1
  89. package/lib/interfaces/PlatformExpressSettings.d.ts +0 -9
  90. package/lib/interfaces/PlatformExpressSettings.js.map +0 -1
  91. package/lib/interfaces/PlatformExpressStaticsOptions.js.map +0 -1
  92. package/lib/interfaces/index.js +0 -6
  93. package/lib/interfaces/index.js.map +0 -1
  94. package/lib/middlewares/rawBodyMiddleware.d.ts +0 -1
  95. package/lib/middlewares/rawBodyMiddleware.js +0 -14
  96. package/lib/middlewares/rawBodyMiddleware.js.map +0 -1
  97. package/lib/middlewares/staticsMiddleware.js.map +0 -1
  98. package/lib/services/PlatformExpressApplication.d.ts +0 -24
  99. package/lib/services/PlatformExpressApplication.js +0 -31
  100. package/lib/services/PlatformExpressApplication.js.map +0 -1
  101. package/lib/services/PlatformExpressHandler.js.map +0 -1
  102. package/lib/services/PlatformExpressRequest.d.ts +0 -22
  103. package/lib/services/PlatformExpressRequest.js.map +0 -1
  104. package/lib/services/PlatformExpressResponse.js.map +0 -1
  105. package/lib/services/PlatformExpressRouter.d.ts +0 -18
  106. package/lib/services/PlatformExpressRouter.js +0 -34
  107. package/lib/services/PlatformExpressRouter.js.map +0 -1
  108. package/lib/services/index.d.ts +0 -5
  109. package/lib/services/index.js +0 -9
  110. package/lib/services/index.js.map +0 -1
@@ -0,0 +1,27 @@
1
+ import { RouterSettings } from "./routerSettings.js";
2
+ /**
3
+ * Specify the behavior of the router controller.
4
+ *
5
+ * ```typescript
6
+ * @Controller("/")
7
+ * @CaseSensitive(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 caseSensitive
20
+ * @returns {Function}
21
+ * @decorator
22
+ * @express
23
+ */
24
+ export function CaseSensitive(caseSensitive) {
25
+ return RouterSettings({ caseSensitive });
26
+ }
27
+ //# sourceMappingURL=caseSensitive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"caseSensitive.js","sourceRoot":"","sources":["../../../src/decorators/caseSensitive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,aAAa,CAAC,aAAsB;IAClD,OAAO,cAAc,CAAC,EAAC,aAAa,EAAC,CAAC,CAAC;AACzC,CAAC","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"]}
@@ -0,0 +1,27 @@
1
+ import { RouterSettings } from "./routerSettings.js";
2
+ /**
3
+ * Specify the behavior of the router controller.
4
+ *
5
+ * ```typescript
6
+ * @Controller("/")
7
+ * @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
+ * @param mergeParams
20
+ * @returns {Function}
21
+ * @decorator
22
+ * @express
23
+ */
24
+ export function MergeParams(mergeParams = true) {
25
+ return RouterSettings({ mergeParams });
26
+ }
27
+ //# sourceMappingURL=mergeParams.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeParams.js","sourceRoot":"","sources":["../../../src/decorators/mergeParams.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,WAAW,CAAC,cAAuB,IAAI;IACrD,OAAO,cAAc,CAAC,EAAC,WAAW,EAAC,CAAC,CAAC;AACvC,CAAC","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"]}
@@ -0,0 +1,28 @@
1
+ import { ROUTER_OPTIONS } from "@tsed/common";
2
+ import { StoreMerge } from "@tsed/core";
3
+ /**
4
+ * Specify the behavior of the router controller.
5
+ *
6
+ * ```typescript
7
+ * @Controller("/")
8
+ * @RouterSettings({mergeParams: true})
9
+ * class MyCtrl {
10
+ *
11
+ * }
12
+ * ```
13
+ *
14
+ * Property | Description | Default
15
+ * ---|---|---
16
+ * caseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.
17
+ * 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
18
+ * strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.
19
+ *
20
+ * @returns {(target:any)=>void}
21
+ * @decorator
22
+ * @param routerOptions
23
+ * @express
24
+ */
25
+ export function RouterSettings(routerOptions) {
26
+ return StoreMerge(ROUTER_OPTIONS, routerOptions);
27
+ }
28
+ //# sourceMappingURL=routerSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routerSettings.js","sourceRoot":"","sources":["../../../src/decorators/routerSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AAGtC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,cAAc,CAAC,aAA4B;IACzD,OAAO,UAAU,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;AACnD,CAAC","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"]}
@@ -0,0 +1,27 @@
1
+ import { RouterSettings } from "./routerSettings.js";
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"]}
@@ -0,0 +1,5 @@
1
+ import { PlatformBuilder, PlatformTest } from "@tsed/common";
2
+ import { PlatformExpress } from "./components/PlatformExpress.js";
3
+ PlatformTest.adapter = PlatformExpress;
4
+ PlatformBuilder.adapter = PlatformExpress;
5
+ //# sourceMappingURL=exports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAE7D,YAAY,CAAC,OAAO,GAAG,eAAsB,CAAC;AAC9C,eAAe,CAAC,OAAO,GAAG,eAAsB,CAAC","sourcesContent":["import {PlatformBuilder, PlatformTest} from \"@tsed/common\";\nimport {PlatformExpress} from \"./components/PlatformExpress\";\n\nPlatformTest.adapter = PlatformExpress as any;\nPlatformBuilder.adapter = PlatformExpress as any;\n"]}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @file Automatically generated by barrelsby.
3
+ */
4
+ export * from "./exports.js";
5
+ export * from "./components/PlatformExpress.js";
6
+ export * from "./decorators/caseSensitive.js";
7
+ export * from "./decorators/mergeParams.js";
8
+ export * from "./decorators/routerSettings.js";
9
+ export * from "./decorators/strict.js";
10
+ export * from "./interfaces/PlatformExpressSettings.js";
11
+ export * from "./interfaces/PlatformExpressStaticsOptions.js";
12
+ export * from "./interfaces/interfaces.js";
13
+ export * from "./middlewares/staticsMiddleware.js";
14
+ export * from "./services/PlatformExpressHandler.js";
15
+ export * from "./services/PlatformExpressRequest.js";
16
+ export * from "./services/PlatformExpressResponse.js";
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,sCAAsC,CAAC;AACrD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./exports\";\nexport * from \"./components/PlatformExpress\";\nexport * from \"./decorators/caseSensitive\";\nexport * from \"./decorators/mergeParams\";\nexport * from \"./decorators/routerSettings\";\nexport * from \"./decorators/strict\";\nexport * from \"./interfaces/PlatformExpressSettings\";\nexport * from \"./interfaces/PlatformExpressStaticsOptions\";\nexport * from \"./interfaces/interfaces\";\nexport * from \"./middlewares/staticsMiddleware\";\nexport * from \"./services/PlatformExpressHandler\";\nexport * from \"./services/PlatformExpressRequest\";\nexport * from \"./services/PlatformExpressResponse\";\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=PlatformExpressSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformExpressSettings.js","sourceRoot":"","sources":["../../../src/interfaces/PlatformExpressSettings.ts"],"names":[],"mappings":"","sourcesContent":["import type {RouterOptions} from \"express\";\nimport type {OptionsJson, OptionsText, Options, OptionsUrlencoded} from \"body-parser\";\nimport type {NextHandleFunction} from \"connect\";\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 * Express application\n */\n app?: Express.Application;\n\n /**\n * body parser configuration\n */\n bodyParser?: {\n json?: (opts?: OptionsJson) => NextHandleFunction | OptionsJson;\n text?: (opts?: OptionsText) => NextHandleFunction | OptionsText;\n raw?: (opts?: Options) => NextHandleFunction | Options;\n urlencoded?: (opts?: OptionsUrlencoded) => NextHandleFunction | OptionsUrlencoded;\n };\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=PlatformExpressStaticsOptions.js.map
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import Express from \"express\";\nimport {PlatformExpressSettings} from \"./PlatformExpressSettings\";\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,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,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -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,8 @@
1
+ import { PlatformRequest } from "@tsed/common";
2
+ /**
3
+ * @platform
4
+ * @express
5
+ */
6
+ export class PlatformExpressRequest extends PlatformRequest {
7
+ }
8
+ //# sourceMappingURL=PlatformExpressRequest.js.map
@@ -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;AAG9D;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,eAAgC;CAAG","sourcesContent":["import {PlatformContext, PlatformRequest} from \"@tsed/common\";\nimport type Express from \"express\";\n\n/**\n * @platform\n * @express\n */\nexport class PlatformExpressRequest extends PlatformRequest<Express.Request> {}\n"]}
@@ -0,0 +1,8 @@
1
+ import { PlatformResponse } from "@tsed/common";
2
+ /**
3
+ * @platform
4
+ * @express
5
+ */
6
+ export class PlatformExpressResponse extends PlatformResponse {
7
+ }
8
+ //# sourceMappingURL=PlatformExpressResponse.js.map
@@ -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,75 @@
1
+ import Express, { RouterOptions } from "express";
2
+ import { InjectorService, PlatformAdapter, PlatformBuilder, PlatformContext, PlatformHandler, PlatformMulter, PlatformMulterSettings, PlatformRequest, PlatformResponse, PlatformStaticsOptions } from "@tsed/common";
3
+ import { Type } from "@tsed/core";
4
+ import { PlatformExpressHandler } from "../services/PlatformExpressHandler";
5
+ import { PlatformExpressResponse } from "../services/PlatformExpressResponse";
6
+ import { PlatformExpressRequest } from "../services/PlatformExpressRequest";
7
+ import { PlatformExpressStaticsOptions } from "../interfaces/PlatformExpressStaticsOptions";
8
+ declare module "express" {
9
+ interface Request {
10
+ id: string;
11
+ $ctx: PlatformContext;
12
+ }
13
+ }
14
+ declare global {
15
+ namespace TsED {
16
+ interface Router extends Express.Router {
17
+ }
18
+ interface Application extends Express.Application {
19
+ }
20
+ interface StaticsOptions extends PlatformExpressStaticsOptions {
21
+ }
22
+ interface Request extends Express.Request {
23
+ id: string;
24
+ $ctx: PlatformContext;
25
+ }
26
+ }
27
+ }
28
+ /**
29
+ * @platform
30
+ * @express
31
+ */
32
+ export declare class PlatformExpress implements PlatformAdapter<Express.Application, Express.Router> {
33
+ #private;
34
+ protected injector: InjectorService;
35
+ readonly providers: ({
36
+ provide: typeof PlatformHandler;
37
+ useClass: typeof PlatformExpressHandler;
38
+ } | {
39
+ provide: typeof PlatformResponse;
40
+ useClass: typeof PlatformExpressResponse;
41
+ } | {
42
+ provide: typeof PlatformRequest;
43
+ useClass: typeof PlatformExpressRequest;
44
+ })[];
45
+ constructor(injector: InjectorService);
46
+ /**
47
+ * Create new serverless application. In this mode, the component scan are disabled.
48
+ * @param module
49
+ * @param settings
50
+ */
51
+ static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<Express.Application, Express.Router>;
52
+ /**
53
+ * Bootstrap a server application
54
+ * @param module
55
+ * @param settings
56
+ */
57
+ static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<Express.Application, Express.Router>>;
58
+ onInit(): void;
59
+ useRouter(): this;
60
+ beforeLoadRoutes(): Promise<void>;
61
+ afterLoadRoutes(): Promise<void>;
62
+ useContext(): this;
63
+ multipart(options: PlatformMulterSettings): PlatformMulter;
64
+ app(): {
65
+ app: any;
66
+ callback(): any;
67
+ };
68
+ router(routerOptions?: Partial<RouterOptions>): {
69
+ router: import("express-serve-static-core").Router;
70
+ callback(): import("express-serve-static-core").Router;
71
+ };
72
+ statics(endpoint: string, options: PlatformStaticsOptions): (request: any, response: any, next: any) => void;
73
+ bodyParser(type: "json" | "raw" | "text" | "urlencoded", additionalOptions?: any): any;
74
+ private configureViewsEngine;
75
+ }
File without changes
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @file Automatically generated by barrelsby.
3
+ */
4
+ export * from "./exports";
5
+ export * from "./components/PlatformExpress";
6
+ export * from "./decorators/caseSensitive";
7
+ export * from "./decorators/mergeParams";
8
+ export * from "./decorators/routerSettings";
9
+ export * from "./decorators/strict";
10
+ export * from "./interfaces/PlatformExpressSettings";
11
+ export * from "./interfaces/PlatformExpressStaticsOptions";
12
+ export * from "./interfaces/interfaces";
13
+ export * from "./middlewares/staticsMiddleware";
14
+ export * from "./services/PlatformExpressHandler";
15
+ export * from "./services/PlatformExpressRequest";
16
+ export * from "./services/PlatformExpressResponse";
@@ -0,0 +1,23 @@
1
+ /// <reference types="express-serve-static-core" />
2
+ import type { RouterOptions } from "express";
3
+ import type { OptionsJson, OptionsText, Options, OptionsUrlencoded } from "body-parser";
4
+ import type { NextHandleFunction } from "connect";
5
+ export interface PlatformExpressSettings {
6
+ /**
7
+ * Global configuration for the Express.Router. See express [documentation](http://expressjs.com/en/api.html#express.router).
8
+ */
9
+ router?: RouterOptions;
10
+ /**
11
+ * Express application
12
+ */
13
+ app?: Express.Application;
14
+ /**
15
+ * body parser configuration
16
+ */
17
+ bodyParser?: {
18
+ json?: (opts?: OptionsJson) => NextHandleFunction | OptionsJson;
19
+ text?: (opts?: OptionsText) => NextHandleFunction | OptionsText;
20
+ raw?: (opts?: Options) => NextHandleFunction | Options;
21
+ urlencoded?: (opts?: OptionsUrlencoded) => NextHandleFunction | OptionsUrlencoded;
22
+ };
23
+ }
@@ -1,7 +1,5 @@
1
1
  import Express from "express";
2
2
  import { PlatformExpressSettings } from "./PlatformExpressSettings";
3
- export * from "./PlatformExpressSettings";
4
- export * from "./PlatformExpressStaticsOptions";
5
3
  declare global {
6
4
  namespace TsED {
7
5
  interface Configuration {
@@ -0,0 +1,8 @@
1
+ import { PlatformRequest } from "@tsed/common";
2
+ import type Express from "express";
3
+ /**
4
+ * @platform
5
+ * @express
6
+ */
7
+ export declare class PlatformExpressRequest extends PlatformRequest<Express.Request> {
8
+ }
package/package.json CHANGED
@@ -1,11 +1,26 @@
1
1
  {
2
2
  "name": "@tsed/platform-express",
3
- "version": "7.0.0-alpha.1",
3
+ "version": "7.0.0-beta.10",
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
+ "module": "./lib/esm/index.js",
9
+ "typings": "./lib/types/index.d.ts",
10
+ "exports": {
11
+ "types": "./lib/types/index.d.ts",
12
+ "import": "./lib/esm/index.js",
13
+ "require": "./lib/cjs/index.js",
14
+ "default": "./lib/esm/index.js"
15
+ },
16
+ "scripts": {
17
+ "build": "yarn barrels && yarn run build:esm && yarn run build:cjs",
18
+ "build:cjs": "tsc --build tsconfig.compile.json",
19
+ "build:esm": "tsc --build tsconfig.compile.esm.json",
20
+ "barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\"",
21
+ "start": "ts-node -r tsconfig-paths/register test/app/index.ts",
22
+ "start:emulate": "ts-node -r tsconfig-paths/register test/app/emulate.ts"
23
+ },
9
24
  "keywords": [
10
25
  "Express",
11
26
  "TypeScript",
@@ -33,45 +48,69 @@
33
48
  "bugs": {
34
49
  "url": "https://github.com/tsedio/tsed/issues"
35
50
  },
36
- "homepage": "https://github.com/tsedio/tsed/tree/alpha/packages/platform/platform-express",
51
+ "homepage": "https://github.com/tsedio/tsed/tree/beta/packages/platform/platform-express",
37
52
  "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
- },
42
53
  "dependencies": {
43
54
  "express": "^4.17.1",
44
55
  "multer": "^1.4.2",
45
- "tslib": "2.2.0"
56
+ "tslib": "2.3.1"
46
57
  },
47
58
  "devDependencies": {
48
- "@tsed/common": "7.0.0-alpha.1",
49
- "@tsed/core": "7.0.0-alpha.1",
50
- "@tsed/di": "7.0.0-alpha.1",
51
- "@tsed/platform-test-utils": "7.0.0-alpha.1",
52
- "@types/body-parser": "1.19.0",
53
- "@types/compression": "1.7.0",
59
+ "@tsed/common": "7.0.0-beta.10",
60
+ "@tsed/core": "7.0.0-beta.10",
61
+ "@tsed/di": "7.0.0-beta.10",
62
+ "@tsed/platform-test-utils": "7.0.0-beta.10",
63
+ "@tsed/platform-views": "7.0.0-beta.10",
64
+ "@types/body-parser": "1.19.2",
65
+ "@types/compression": "1.7.2",
54
66
  "@types/cookie-parser": "1.4.2",
55
67
  "@types/express": "^4.17.7",
56
- "@types/express-session": "1.17.0",
57
- "@types/method-override": "0.0.31",
68
+ "@types/express-session": "1.17.4",
69
+ "@types/method-override": "0.0.32",
58
70
  "@types/multer": "^1.4.3",
59
- "body-parser": "1.19.0",
71
+ "body-parser": "1.19.2",
60
72
  "compression": "1.7.4",
61
- "cookie-parser": "1.4.5",
73
+ "cookie-parser": "1.4.6",
62
74
  "cors": "2.8.5",
63
- "express-session": "1.17.1",
75
+ "express-session": "1.17.2",
64
76
  "method-override": "3.0.0"
65
77
  },
66
78
  "peerDependencies": {
67
- "@tsed/common": "^7.0.0-alpha.1",
68
- "@tsed/core": "^7.0.0-alpha.1",
69
- "@tsed/di": "^7.0.0-alpha.1",
70
- "@tsed/json-mapper": "^7.0.0-alpha.1",
71
- "@tsed/logger": "^5.16.0",
72
- "@tsed/openspec": "^7.0.0-alpha.1",
73
- "@tsed/schema": "^7.0.0-alpha.1",
79
+ "@tsed/common": "^7.0.0-beta.10",
80
+ "@tsed/core": "^7.0.0-beta.10",
81
+ "@tsed/di": "^7.0.0-beta.10",
82
+ "@tsed/json-mapper": "^7.0.0-beta.10",
83
+ "@tsed/logger": ">=6.1.1",
84
+ "@tsed/openspec": "^7.0.0-beta.10",
85
+ "@tsed/platform-views": "^7.0.0-beta.10",
86
+ "@tsed/schema": "^7.0.0-beta.10",
74
87
  "@types/multer": "^1.4.5",
75
88
  "body-parser": "1.19.0"
89
+ },
90
+ "peerDependenciesMeta": {
91
+ "@tsed/common": {
92
+ "optional": false
93
+ },
94
+ "@tsed/core": {
95
+ "optional": false
96
+ },
97
+ "@tsed/di": {
98
+ "optional": false
99
+ },
100
+ "@tsed/json-mapper": {
101
+ "optional": false
102
+ },
103
+ "@tsed/openspec": {
104
+ "optional": false
105
+ },
106
+ "@tsed/platform-views": {
107
+ "optional": true
108
+ },
109
+ "@tsed/schema": {
110
+ "optional": false
111
+ },
112
+ "@tsed/logger": {
113
+ "optional": false
114
+ }
76
115
  }
77
116
  }
package/readme.md CHANGED
@@ -44,14 +44,12 @@ Please read [contributing guidelines here](https://tsed.io/CONTRIBUTING.html)
44
44
 
45
45
  <a href="https://github.com/tsedio/ts-express-decorators/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>
46
46
 
47
-
48
47
  ## Backers
49
48
 
50
49
  Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]
51
50
 
52
51
  <a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/backers.svg?width=890"></a>
53
52
 
54
-
55
53
  ## Sponsors
56
54
 
57
55
  Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
@@ -0,0 +1,12 @@
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": ["node_modules", "test", "lib", "benchmark", "coverage", "spec", "**/*.benchmark.ts", "**/*.spec.ts", "keys", "jest.config.js"]
12
+ }