@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
@@ -1,28 +0,0 @@
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
- static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformExpress>;
24
- protected useRouter(): this;
25
- protected useContext(): this;
26
- protected loadRoutes(): Promise<void>;
27
- private configureViewsEngine;
28
- }
@@ -1,79 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PlatformExpress = void 0;
4
- const common_1 = require("@tsed/common");
5
- const core_1 = require("@tsed/core");
6
- const rawBodyMiddleware_1 = require("../middlewares/rawBodyMiddleware");
7
- const services_1 = require("../services");
8
- /**
9
- * @platform
10
- * @express
11
- */
12
- class PlatformExpress extends common_1.PlatformBuilder {
13
- static async bootstrap(module, settings = {}) {
14
- return this.build(PlatformExpress).bootstrap(module, settings);
15
- }
16
- useRouter() {
17
- this.logger.info("Mount app router");
18
- this.app.getApp().use(rawBodyMiddleware_1.rawBodyMiddleware);
19
- this.app.getApp().use(this.app.getRouter());
20
- return this;
21
- }
22
- useContext() {
23
- this.logger.info("Mount app context");
24
- const invoke = common_1.createContext(this.injector);
25
- this.app.getApp().use(async (request, response, next) => {
26
- await invoke({ request, response });
27
- return next();
28
- });
29
- return this;
30
- }
31
- async loadRoutes() {
32
- // disable x-powered-by header
33
- this.injector.settings.get("env") === core_1.Env.PROD && this.app.getApp().disable("x-powered-by");
34
- this.configureViewsEngine();
35
- await super.loadRoutes();
36
- // NOT FOUND
37
- this.app.use((req, res, next) => {
38
- var _a;
39
- !res.headersSent && ((_a = this.injector.get(common_1.PlatformExceptions)) === null || _a === void 0 ? void 0 : _a.resourceNotFound(req.$ctx));
40
- });
41
- // EXCEPTION FILTERS
42
- this.app.use((err, req, res, next) => {
43
- var _a;
44
- !res.headersSent && ((_a = this.injector.get(common_1.PlatformExceptions)) === null || _a === void 0 ? void 0 : _a.catch(err, req.$ctx));
45
- });
46
- }
47
- configureViewsEngine() {
48
- const platformViews = this.injector.get(common_1.PlatformViews);
49
- platformViews.getEngines().forEach(({ extension, engine }) => {
50
- this.app.getApp().engine(extension, engine.render);
51
- });
52
- platformViews.viewEngine && this.app.getApp().set("view engine", platformViews.viewEngine);
53
- platformViews.root && this.app.getApp().set("views", platformViews.root);
54
- }
55
- }
56
- exports.PlatformExpress = PlatformExpress;
57
- PlatformExpress.providers = [
58
- {
59
- provide: common_1.PlatformApplication,
60
- useClass: services_1.PlatformExpressApplication
61
- },
62
- {
63
- provide: common_1.PlatformRouter,
64
- useClass: services_1.PlatformExpressRouter
65
- },
66
- {
67
- provide: common_1.PlatformHandler,
68
- useClass: services_1.PlatformExpressHandler
69
- },
70
- {
71
- provide: common_1.PlatformResponse,
72
- useClass: services_1.PlatformExpressResponse
73
- },
74
- {
75
- provide: common_1.PlatformRequest,
76
- useClass: services_1.PlatformExpressRequest
77
- }
78
- ];
79
- //# 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 PlatformViews\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\";\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 static async bootstrap(module: Type<any>, settings: Partial<TsED.Configuration> = {}): Promise<PlatformExpress> {\n return this.build<PlatformExpress>(PlatformExpress).bootstrap(module, settings);\n }\n\n protected useRouter(): this {\n this.logger.info(\"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.info(\"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 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 configureViewsEngine() {\n const platformViews = this.injector.get<PlatformViews>(PlatformViews)!;\n\n platformViews.getEngines().forEach(({extension, engine}) => {\n this.app.getApp().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}\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,4 +0,0 @@
1
- export * from "./routerSettings";
2
- export * from "./caseSensitive";
3
- export * from "./mergeParams";
4
- export * from "./strict";
@@ -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.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from "./interfaces";
2
- export * from "./decorators";
3
- export * from "./services";
4
- export * from "./components/PlatformExpress";
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,9 +0,0 @@
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
- }
@@ -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
- export declare function rawBodyMiddleware(request: any, response: any, next: any): void;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rawBodyMiddleware = void 0;
4
- function rawBodyMiddleware(request, response, next) {
5
- if (!request.is("multipart/form-data")) {
6
- request.rawBody = "";
7
- request.on("data", (chunk) => {
8
- request.rawBody += chunk;
9
- });
10
- }
11
- next();
12
- }
13
- exports.rawBodyMiddleware = rawBodyMiddleware;
14
- //# sourceMappingURL=rawBodyMiddleware.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rawBodyMiddleware.js","sourceRoot":"","sources":["../../src/middlewares/rawBodyMiddleware.ts"],"names":[],"mappings":";;;AAAA,SAAgB,iBAAiB,CAAC,OAAY,EAAE,QAAa,EAAE,IAAS;IACtE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,qBAAqB,CAAC,EAAE;QACtC,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC;QACrB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;YACnC,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC;QAC3B,CAAC,CAAC,CAAC;KACJ;IAED,IAAI,EAAE,CAAC;AACT,CAAC;AATD,8CASC","sourcesContent":["export function rawBodyMiddleware(request: any, response: any, next: any) {\n if (!request.is(\"multipart/form-data\")) {\n request.rawBody = \"\";\n request.on(\"data\", (chunk: string) => {\n request.rawBody += chunk;\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,24 +0,0 @@
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
- }
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PlatformExpressApplication = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@tsed/common");
6
- const express_1 = tslib_1.__importDefault(require("express"));
7
- const PlatformExpressRouter_1 = require("./PlatformExpressRouter");
8
- /**
9
- * @platform
10
- * @express
11
- */
12
- let PlatformExpressApplication = class PlatformExpressApplication extends PlatformExpressRouter_1.PlatformExpressRouter {
13
- constructor(platformHandler, configuration) {
14
- super(platformHandler, configuration, {
15
- mergeParams: true
16
- });
17
- this.rawApp = configuration.get("express.app") || express_1.default();
18
- }
19
- getApp() {
20
- return this.rawApp;
21
- }
22
- callback() {
23
- return this.rawApp;
24
- }
25
- };
26
- PlatformExpressApplication = tslib_1.__decorate([
27
- tslib_1.__param(0, common_1.Inject()), tslib_1.__param(1, common_1.Configuration()),
28
- tslib_1.__metadata("design:paramtypes", [common_1.PlatformHandler, Object])
29
- ], PlatformExpressApplication);
30
- exports.PlatformExpressApplication = PlatformExpressApplication;
31
- //# sourceMappingURL=PlatformExpressApplication.js.map
@@ -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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformExpressHandler.js","sourceRoot":"","sources":["../../src/services/PlatformExpressHandler.ts"],"names":[],"mappings":";;;AAAA,yCAA6F;AAE7F;;;GAGG;AACH,MAAa,sBAAuB,SAAQ,wBAAe;IAC/C,gBAAgB,CAAC,QAAyB;QAClD,IAAI,QAAQ,CAAC,IAAI,KAAK,oBAAW,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;AAtBD,wDAsBC","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"]}
@@ -1,22 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformExpressRequest.js","sourceRoot":"","sources":["../../src/services/PlatformExpressRequest.ts"],"names":[],"mappings":";;;AAAA,yCAA8D;AAmB9D;;;GAGG;AACH,MAAa,sBAAuB,SAAQ,wBAAgC;CAAG;AAA/E,wDAA+E","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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformExpressResponse.js","sourceRoot":"","sources":["../../src/services/PlatformExpressResponse.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAS9C;;;GAGG;AACH,MAAa,uBAAwB,SAAQ,yBAAkC;CAAG;AAAlF,0DAAkF","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"]}
@@ -1,18 +0,0 @@
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
- }
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PlatformExpressRouter = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@tsed/common");
6
- const di_1 = require("@tsed/di");
7
- const express_1 = tslib_1.__importDefault(require("express"));
8
- const staticsMiddleware_1 = require("../middlewares/staticsMiddleware");
9
- /**
10
- * @platform
11
- * @express
12
- */
13
- let PlatformExpressRouter = class PlatformExpressRouter extends common_1.PlatformRouter {
14
- constructor(platform, configuration, routerOptions = {}) {
15
- var _a;
16
- super(platform);
17
- const options = Object.assign({
18
- mergeParams: true
19
- }, ((_a = configuration.express) === null || _a === void 0 ? void 0 : _a.router) || {}, routerOptions);
20
- this.rawRouter = this.raw = express_1.default.Router(options);
21
- }
22
- statics(endpoint, options) {
23
- const { root, ...props } = options;
24
- this.use(endpoint, staticsMiddleware_1.staticsMiddleware(root, props));
25
- return this;
26
- }
27
- };
28
- PlatformExpressRouter = tslib_1.__decorate([
29
- tslib_1.__param(1, di_1.Configuration()),
30
- tslib_1.__param(2, di_1.Inject(common_1.PLATFORM_ROUTER_OPTIONS)),
31
- tslib_1.__metadata("design:paramtypes", [common_1.PlatformHandler, Object, Object])
32
- ], PlatformExpressRouter);
33
- exports.PlatformExpressRouter = PlatformExpressRouter;
34
- //# sourceMappingURL=PlatformExpressRouter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformExpressRouter.js","sourceRoot":"","sources":["../../src/services/PlatformExpressRouter.ts"],"names":[],"mappings":";;;;AAAA,yCAA8G;AAC9G,iCAA+C;AAC/C,8DAA8B;AAE9B,wEAAmE;AAQnE;;;GAGG;AACH,IAAa,qBAAqB,GAAlC,MAAa,qBAAsB,SAAQ,uBAA8B;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,iBAAO,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,qCAAiB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;QAEnD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAzBY,qBAAqB;IAG7B,mBAAA,kBAAa,EAAE,CAAA;IACf,mBAAA,WAAM,CAAC,gCAAuB,CAAC,CAAA;6CAFtB,wBAAe;GAFhB,qBAAqB,CAyBjC;AAzBY,sDAAqB","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"]}
@@ -1,5 +0,0 @@
1
- export * from "./PlatformExpressApplication";
2
- export * from "./PlatformExpressHandler";
3
- export * from "./PlatformExpressResponse";
4
- export * from "./PlatformExpressRequest";
5
- export * from "./PlatformExpressRouter";
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./PlatformExpressApplication"), exports);
5
- tslib_1.__exportStar(require("./PlatformExpressHandler"), exports);
6
- tslib_1.__exportStar(require("./PlatformExpressResponse"), exports);
7
- tslib_1.__exportStar(require("./PlatformExpressRequest"), exports);
8
- tslib_1.__exportStar(require("./PlatformExpressRouter"), exports);
9
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;AAAA,uEAA6C;AAC7C,mEAAyC;AACzC,oEAA0C;AAC1C,mEAAyC;AACzC,kEAAwC","sourcesContent":["export * from \"./PlatformExpressApplication\";\nexport * from \"./PlatformExpressHandler\";\nexport * from \"./PlatformExpressResponse\";\nexport * from \"./PlatformExpressRequest\";\nexport * from \"./PlatformExpressRouter\";\n"]}