@tsed/platform-express 7.0.0-beta.2 → 7.0.0-beta.20

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 (96) hide show
  1. package/coverage.json +6 -0
  2. package/jest.config.js +9 -0
  3. package/lib/cjs/components/PlatformExpress.js +126 -66
  4. package/lib/cjs/components/PlatformExpress.js.map +1 -1
  5. package/lib/cjs/exports.js +7 -0
  6. package/lib/cjs/exports.js.map +1 -0
  7. package/lib/cjs/index.js +9 -12
  8. package/lib/cjs/index.js.map +1 -1
  9. package/lib/cjs/interfaces/PlatformExpressSettings.js.map +1 -1
  10. package/lib/cjs/interfaces/interfaces.js +3 -0
  11. package/lib/cjs/interfaces/interfaces.js.map +1 -0
  12. package/lib/cjs/middlewares/staticsMiddleware.js +1 -1
  13. package/lib/cjs/middlewares/staticsMiddleware.js.map +1 -1
  14. package/lib/cjs/package.json +3 -0
  15. package/lib/esm/components/PlatformExpress.js +126 -48
  16. package/lib/esm/components/PlatformExpress.js.map +1 -1
  17. package/lib/esm/exports.js +5 -0
  18. package/lib/esm/exports.js.map +1 -0
  19. package/lib/esm/index.js +9 -12
  20. package/lib/esm/index.js.map +1 -1
  21. package/lib/esm/interfaces/PlatformExpressSettings.js.map +1 -1
  22. package/lib/esm/interfaces/interfaces.js +2 -0
  23. package/lib/esm/interfaces/interfaces.js.map +1 -0
  24. package/lib/esm/package.json +3 -0
  25. package/lib/types/components/PlatformExpress.d.ts +40 -22
  26. package/lib/types/exports.d.ts +1 -0
  27. package/lib/types/index.d.ts +8 -3
  28. package/lib/types/interfaces/PlatformExpressSettings.d.ts +15 -1
  29. package/lib/types/interfaces/{index.d.ts → interfaces.d.ts} +6 -4
  30. package/package.json +64 -26
  31. package/readme.md +3 -4
  32. package/tsconfig.compile.esm.json +1 -12
  33. package/lib/cjs/decorators/caseSensitive.js +0 -31
  34. package/lib/cjs/decorators/caseSensitive.js.map +0 -1
  35. package/lib/cjs/decorators/index.js +0 -8
  36. package/lib/cjs/decorators/index.js.map +0 -1
  37. package/lib/cjs/decorators/mergeParams.js +0 -31
  38. package/lib/cjs/decorators/mergeParams.js.map +0 -1
  39. package/lib/cjs/decorators/routerSettings.js +0 -32
  40. package/lib/cjs/decorators/routerSettings.js.map +0 -1
  41. package/lib/cjs/decorators/strict.js +0 -31
  42. package/lib/cjs/decorators/strict.js.map +0 -1
  43. package/lib/cjs/interfaces/index.js +0 -6
  44. package/lib/cjs/interfaces/index.js.map +0 -1
  45. package/lib/cjs/middlewares/rawBodyMiddleware.js +0 -27
  46. package/lib/cjs/middlewares/rawBodyMiddleware.js.map +0 -1
  47. package/lib/cjs/services/PlatformExpressApplication.js +0 -32
  48. package/lib/cjs/services/PlatformExpressApplication.js.map +0 -1
  49. package/lib/cjs/services/PlatformExpressHandler.js +0 -31
  50. package/lib/cjs/services/PlatformExpressHandler.js.map +0 -1
  51. package/lib/cjs/services/PlatformExpressRequest.js +0 -12
  52. package/lib/cjs/services/PlatformExpressRequest.js.map +0 -1
  53. package/lib/cjs/services/PlatformExpressResponse.js +0 -12
  54. package/lib/cjs/services/PlatformExpressResponse.js.map +0 -1
  55. package/lib/cjs/services/PlatformExpressRouter.js +0 -34
  56. package/lib/cjs/services/PlatformExpressRouter.js.map +0 -1
  57. package/lib/cjs/services/index.js +0 -9
  58. package/lib/cjs/services/index.js.map +0 -1
  59. package/lib/esm/decorators/caseSensitive.js +0 -27
  60. package/lib/esm/decorators/caseSensitive.js.map +0 -1
  61. package/lib/esm/decorators/index.js +0 -5
  62. package/lib/esm/decorators/index.js.map +0 -1
  63. package/lib/esm/decorators/mergeParams.js +0 -27
  64. package/lib/esm/decorators/mergeParams.js.map +0 -1
  65. package/lib/esm/decorators/routerSettings.js +0 -28
  66. package/lib/esm/decorators/routerSettings.js.map +0 -1
  67. package/lib/esm/decorators/strict.js +0 -27
  68. package/lib/esm/decorators/strict.js.map +0 -1
  69. package/lib/esm/interfaces/index.js +0 -3
  70. package/lib/esm/interfaces/index.js.map +0 -1
  71. package/lib/esm/middlewares/rawBodyMiddleware.js +0 -22
  72. package/lib/esm/middlewares/rawBodyMiddleware.js.map +0 -1
  73. package/lib/esm/services/PlatformExpressApplication.js +0 -29
  74. package/lib/esm/services/PlatformExpressApplication.js.map +0 -1
  75. package/lib/esm/services/PlatformExpressHandler.js +0 -27
  76. package/lib/esm/services/PlatformExpressHandler.js.map +0 -1
  77. package/lib/esm/services/PlatformExpressRequest.js +0 -8
  78. package/lib/esm/services/PlatformExpressRequest.js.map +0 -1
  79. package/lib/esm/services/PlatformExpressResponse.js +0 -8
  80. package/lib/esm/services/PlatformExpressResponse.js.map +0 -1
  81. package/lib/esm/services/PlatformExpressRouter.js +0 -31
  82. package/lib/esm/services/PlatformExpressRouter.js.map +0 -1
  83. package/lib/esm/services/index.js +0 -6
  84. package/lib/esm/services/index.js.map +0 -1
  85. package/lib/types/decorators/caseSensitive.d.ts +0 -23
  86. package/lib/types/decorators/index.d.ts +0 -4
  87. package/lib/types/decorators/mergeParams.d.ts +0 -23
  88. package/lib/types/decorators/routerSettings.d.ts +0 -24
  89. package/lib/types/decorators/strict.d.ts +0 -23
  90. package/lib/types/middlewares/rawBodyMiddleware.d.ts +0 -4
  91. package/lib/types/services/PlatformExpressApplication.d.ts +0 -24
  92. package/lib/types/services/PlatformExpressHandler.d.ts +0 -9
  93. package/lib/types/services/PlatformExpressRequest.d.ts +0 -22
  94. package/lib/types/services/PlatformExpressResponse.d.ts +0 -14
  95. package/lib/types/services/PlatformExpressRouter.d.ts +0 -18
  96. package/lib/types/services/index.d.ts +0 -5
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":";;;AAGA,yEAA0C;AAC1C,+EAAgD","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,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rawBodyMiddleware = void 0;
4
- const tslib_1 = require("tslib");
5
- const bytes_1 = (0, tslib_1.__importDefault)(require("bytes"));
6
- const limit = bytes_1.default.parse("100kb");
7
- function isLimitReached(length) {
8
- return limit !== null && length !== null && length > limit;
9
- }
10
- function getContentLength(request) {
11
- const contentLength = request.get("content-length");
12
- return contentLength != null && !isNaN(contentLength) ? parseInt(contentLength, 10) : null;
13
- }
14
- function rawBodyMiddleware(request, response, next) {
15
- if (request.method !== "GET") {
16
- const length = getContentLength(request);
17
- if (!isLimitReached(length) && request.is(["application/x-www-form-urlencoded", "application/json"])) {
18
- request.rawBody = "";
19
- request.on("data", (chunk) => {
20
- request.rawBody += chunk;
21
- });
22
- }
23
- }
24
- next();
25
- }
26
- exports.rawBodyMiddleware = rawBodyMiddleware;
27
- //# sourceMappingURL=rawBodyMiddleware.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rawBodyMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/rawBodyMiddleware.ts"],"names":[],"mappings":";;;;AACA,+DAA0B;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,32 +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 = (0, 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") || (0, express_1.default)();
18
- }
19
- getApp() {
20
- return this.rawApp;
21
- }
22
- callback() {
23
- return this.rawApp;
24
- }
25
- };
26
- PlatformExpressApplication = (0, tslib_1.__decorate)([
27
- (0, tslib_1.__param)(0, (0, common_1.Inject)()),
28
- (0, tslib_1.__param)(1, (0, common_1.Configuration)()),
29
- (0, tslib_1.__metadata)("design:paramtypes", [common_1.PlatformHandler, Object])
30
- ], PlatformExpressApplication);
31
- exports.PlatformExpressApplication = PlatformExpressApplication;
32
- //# sourceMappingURL=PlatformExpressApplication.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformExpressApplication.js","sourceRoot":"","sources":["../../../src/services/PlatformExpressApplication.ts"],"names":[],"mappings":";;;;AAAA,yCAAwG;AACxG,mEAA8B;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,IAAA,iBAAO,GAAE,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,wBAAA,IAAA,eAAM,GAAE,CAAA;IAAoC,wBAAA,IAAA,sBAAa,GAAE,CAAA;kDAAjC,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,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PlatformExpressHandler = void 0;
4
- const common_1 = require("@tsed/common");
5
- /**
6
- * @platform
7
- * @express
8
- */
9
- class PlatformExpressHandler extends common_1.PlatformHandler {
10
- createRawHandler(metadata) {
11
- if (metadata.type === common_1.HandlerType.ERR_MIDDLEWARE) {
12
- const handler = this.compileHandler(metadata);
13
- return async (err, req, res, next) => handler({
14
- err,
15
- next,
16
- $ctx: req.$ctx
17
- });
18
- }
19
- return super.createRawHandler(metadata);
20
- }
21
- async onCtxRequest(requestOptions) {
22
- try {
23
- return await super.onCtxRequest(requestOptions);
24
- }
25
- catch (er) {
26
- return this.onError(er, requestOptions);
27
- }
28
- }
29
- }
30
- exports.PlatformExpressHandler = PlatformExpressHandler;
31
- //# sourceMappingURL=PlatformExpressHandler.js.map
@@ -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,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PlatformExpressRequest = void 0;
4
- const common_1 = require("@tsed/common");
5
- /**
6
- * @platform
7
- * @express
8
- */
9
- class PlatformExpressRequest extends common_1.PlatformRequest {
10
- }
11
- exports.PlatformExpressRequest = PlatformExpressRequest;
12
- //# sourceMappingURL=PlatformExpressRequest.js.map
@@ -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,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PlatformExpressResponse = void 0;
4
- const common_1 = require("@tsed/common");
5
- /**
6
- * @platform
7
- * @express
8
- */
9
- class PlatformExpressResponse extends common_1.PlatformResponse {
10
- }
11
- exports.PlatformExpressResponse = PlatformExpressResponse;
12
- //# sourceMappingURL=PlatformExpressResponse.js.map
@@ -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,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 = (0, 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, (0, staticsMiddleware_1.staticsMiddleware)(root, props));
25
- return this;
26
- }
27
- };
28
- PlatformExpressRouter = (0, tslib_1.__decorate)([
29
- (0, tslib_1.__param)(1, (0, di_1.Configuration)()),
30
- (0, tslib_1.__param)(2, (0, di_1.Inject)(common_1.PLATFORM_ROUTER_OPTIONS)),
31
- (0, 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,mEAA8B;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,IAAA,qCAAiB,EAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;QAEnD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAzBY,qBAAqB;IAG7B,wBAAA,IAAA,kBAAa,GAAE,CAAA;IACf,wBAAA,IAAA,WAAM,EAAC,gCAAuB,CAAC,CAAA;kDAFtB,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,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- (0, tslib_1.__exportStar)(require("./PlatformExpressApplication"), exports);
5
- (0, tslib_1.__exportStar)(require("./PlatformExpressHandler"), exports);
6
- (0, tslib_1.__exportStar)(require("./PlatformExpressResponse"), exports);
7
- (0, tslib_1.__exportStar)(require("./PlatformExpressRequest"), exports);
8
- (0, 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,4EAA6C;AAC7C,wEAAyC;AACzC,yEAA0C;AAC1C,wEAAyC;AACzC,uEAAwC","sourcesContent":["export * from \"./PlatformExpressApplication\";\nexport * from \"./PlatformExpressHandler\";\nexport * from \"./PlatformExpressResponse\";\nexport * from \"./PlatformExpressRequest\";\nexport * from \"./PlatformExpressRouter\";\n"]}
@@ -1,27 +0,0 @@
1
- import { RouterSettings } from "./routerSettings";
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
@@ -1 +0,0 @@
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"]}
@@ -1,5 +0,0 @@
1
- export * from "./routerSettings";
2
- export * from "./caseSensitive";
3
- export * from "./mergeParams";
4
- export * from "./strict";
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC","sourcesContent":["export * from \"./routerSettings\";\nexport * from \"./caseSensitive\";\nexport * from \"./mergeParams\";\nexport * from \"./strict\";\n"]}
@@ -1,27 +0,0 @@
1
- import { RouterSettings } from "./routerSettings";
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
@@ -1 +0,0 @@
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"]}
@@ -1,28 +0,0 @@
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
@@ -1 +0,0 @@
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"]}
@@ -1,27 +0,0 @@
1
- import { RouterSettings } from "./routerSettings";
2
- /**
3
- * Specify the behavior of the router controller.
4
- *
5
- * ```typescript
6
- * @Controller("/")
7
- * @Strict(true)
8
- * class MyCtrl {
9
- *
10
- * }
11
- * ```
12
- *
13
- * Property | Description | Default
14
- * ---|---|---
15
- * CaseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.
16
- * MergeParams | Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child’s value take precedence. | false
17
- * Strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.
18
- *
19
- * @param strict
20
- * @returns {Function}
21
- * @decorator
22
- * @express
23
- */
24
- export function Strict(strict) {
25
- return RouterSettings({ strict });
26
- }
27
- //# sourceMappingURL=strict.js.map
@@ -1 +0,0 @@
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"]}
@@ -1,3 +0,0 @@
1
- export * from "./PlatformExpressSettings";
2
- export * from "./PlatformExpressStaticsOptions";
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":"AAGA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC","sourcesContent":["import Express from \"express\";\nimport {PlatformExpressSettings} from \"./PlatformExpressSettings\";\n\nexport * from \"./PlatformExpressSettings\";\nexport * from \"./PlatformExpressStaticsOptions\";\n\ndeclare global {\n namespace TsED {\n export interface Configuration {\n /**\n * Configuration related to Express platform application.\n */\n express: PlatformExpressSettings;\n }\n\n export interface NextFunction extends Express.NextFunction {}\n }\n}\n"]}
@@ -1,22 +0,0 @@
1
- import bytes from "bytes";
2
- const limit = bytes.parse("100kb");
3
- function isLimitReached(length) {
4
- return limit !== null && length !== null && length > limit;
5
- }
6
- function getContentLength(request) {
7
- const contentLength = request.get("content-length");
8
- return contentLength != null && !isNaN(contentLength) ? parseInt(contentLength, 10) : null;
9
- }
10
- export function rawBodyMiddleware(request, response, next) {
11
- if (request.method !== "GET") {
12
- const length = getContentLength(request);
13
- if (!isLimitReached(length) && request.is(["application/x-www-form-urlencoded", "application/json"])) {
14
- request.rawBody = "";
15
- request.on("data", (chunk) => {
16
- request.rawBody += chunk;
17
- });
18
- }
19
- }
20
- next();
21
- }
22
- //# sourceMappingURL=rawBodyMiddleware.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rawBodyMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/rawBodyMiddleware.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAEnC,SAAS,cAAc,CAAC,MAAqB;IAC3C,OAAO,KAAK,KAAK,IAAI,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,GAAG,KAAK,CAAC;AAC7D,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAoC;IAC5D,MAAM,aAAa,GAAQ,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACzD,OAAO,aAAa,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7F,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAoC,EAAE,QAAa,EAAE,IAAS;IAC9F,IAAI,OAAO,CAAC,MAAM,KAAK,KAAK,EAAE;QAC5B,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAEzC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,EAAE,CAAC,CAAC,mCAAmC,EAAE,kBAAkB,CAAC,CAAC,EAAE;YACpG,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC;YACrB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;gBACnC,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC;YAC3B,CAAC,CAAC,CAAC;SACJ;KACF;IAED,IAAI,EAAE,CAAC;AACT,CAAC","sourcesContent":["import {Request} from \"express\";\nimport bytes from \"bytes\";\n\nconst limit = bytes.parse(\"100kb\");\n\nfunction isLimitReached(length: number | null) {\n return limit !== null && length !== null && length > limit;\n}\n\nfunction getContentLength(request: Request & {rawBody: string}) {\n const contentLength: any = request.get(\"content-length\");\n return contentLength != null && !isNaN(contentLength) ? parseInt(contentLength, 10) : null;\n}\n\nexport function rawBodyMiddleware(request: Request & {rawBody: string}, response: any, next: any) {\n if (request.method !== \"GET\") {\n const length = getContentLength(request);\n\n if (!isLimitReached(length) && request.is([\"application/x-www-form-urlencoded\", \"application/json\"])) {\n request.rawBody = \"\";\n request.on(\"data\", (chunk: string) => {\n request.rawBody += chunk;\n });\n }\n }\n\n next();\n}\n"]}
@@ -1,29 +0,0 @@
1
- import { __decorate, __metadata, __param } from "tslib";
2
- import { Configuration, Inject, PlatformHandler } from "@tsed/common";
3
- import Express from "express";
4
- import { PlatformExpressRouter } from "./PlatformExpressRouter";
5
- /**
6
- * @platform
7
- * @express
8
- */
9
- let PlatformExpressApplication = class PlatformExpressApplication extends PlatformExpressRouter {
10
- constructor(platformHandler, configuration) {
11
- super(platformHandler, configuration, {
12
- mergeParams: true
13
- });
14
- this.rawApp = configuration.get("express.app") || Express();
15
- }
16
- getApp() {
17
- return this.rawApp;
18
- }
19
- callback() {
20
- return this.rawApp;
21
- }
22
- };
23
- PlatformExpressApplication = __decorate([
24
- __param(0, Inject()),
25
- __param(1, Configuration()),
26
- __metadata("design:paramtypes", [PlatformHandler, Object])
27
- ], PlatformExpressApplication);
28
- export { PlatformExpressApplication };
29
- //# sourceMappingURL=PlatformExpressApplication.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformExpressApplication.js","sourceRoot":"","sources":["../../../src/services/PlatformExpressApplication.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,aAAa,EAAiB,MAAM,EAAuB,eAAe,EAAC,MAAM,cAAc,CAAC;AACxG,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAU9D;;;GAGG;AACH,IAAa,0BAA0B,GAAvC,MAAa,0BAA2B,SAAQ,qBAAqB;IAKnE,YAAsB,eAAgC,EAAmB,aAA4B;QACnG,KAAK,CAAC,eAAe,EAAE,aAAa,EAAE;YACpC,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,OAAO,EAAE,CAAC;IAC9D,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF,CAAA;AApBY,0BAA0B;IAKxB,WAAA,MAAM,EAAE,CAAA;IAAoC,WAAA,aAAa,EAAE,CAAA;qCAAjC,eAAe;GAL3C,0BAA0B,CAoBtC;SApBY,0BAA0B","sourcesContent":["import {Configuration, createContext, Inject, PlatformApplication, PlatformHandler} from \"@tsed/common\";\nimport Express from \"express\";\nimport {PlatformExpressStaticsOptions} from \"../interfaces/PlatformExpressStaticsOptions\";\nimport {PlatformExpressRouter} from \"./PlatformExpressRouter\";\n\ndeclare global {\n namespace TsED {\n export interface Application extends Express.Application {}\n\n export interface StaticsOptions extends PlatformExpressStaticsOptions {}\n }\n}\n\n/**\n * @platform\n * @express\n */\nexport class PlatformExpressApplication extends PlatformExpressRouter implements PlatformApplication<Express.Application, Express.Router> {\n app: Express.Application;\n rawApp: Express.Application;\n rawRouter: Express.Router;\n\n constructor(@Inject() platformHandler: PlatformHandler, @Configuration() configuration: Configuration) {\n super(platformHandler, configuration, {\n mergeParams: true\n });\n\n this.rawApp = configuration.get(\"express.app\") || Express();\n }\n\n getApp() {\n return this.rawApp;\n }\n\n callback() {\n return this.rawApp;\n }\n}\n"]}
@@ -1,27 +0,0 @@
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
@@ -1 +0,0 @@
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"]}
@@ -1,8 +0,0 @@
1
- import { PlatformRequest } from "@tsed/common";
2
- /**
3
- * @platform
4
- * @express
5
- */
6
- export class PlatformExpressRequest extends PlatformRequest {
7
- }
8
- //# sourceMappingURL=PlatformExpressRequest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformExpressRequest.js","sourceRoot":"","sources":["../../../src/services/PlatformExpressRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,eAAe,EAAC,MAAM,cAAc,CAAC;AAmB9D;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,eAAgC;CAAG","sourcesContent":["import {PlatformContext, PlatformRequest} from \"@tsed/common\";\nimport type Express from \"express\";\n\ndeclare module \"express\" {\n export interface Request {\n id: string;\n $ctx: PlatformContext;\n }\n}\n\ndeclare global {\n namespace TsED {\n export interface Request extends Express.Request {\n id: string;\n $ctx: PlatformContext;\n }\n }\n}\n\n/**\n * @platform\n * @express\n */\nexport class PlatformExpressRequest extends PlatformRequest<Express.Request> {}\n"]}
@@ -1,8 +0,0 @@
1
- import { PlatformResponse } from "@tsed/common";
2
- /**
3
- * @platform
4
- * @express
5
- */
6
- export class PlatformExpressResponse extends PlatformResponse {
7
- }
8
- //# sourceMappingURL=PlatformExpressResponse.js.map
@@ -1 +0,0 @@
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"]}
@@ -1,31 +0,0 @@
1
- import { __decorate, __metadata, __param } from "tslib";
2
- import { PLATFORM_ROUTER_OPTIONS, PlatformHandler, PlatformRouter } from "@tsed/common";
3
- import { Configuration, Inject } from "@tsed/di";
4
- import Express from "express";
5
- import { staticsMiddleware } from "../middlewares/staticsMiddleware";
6
- /**
7
- * @platform
8
- * @express
9
- */
10
- let PlatformExpressRouter = class PlatformExpressRouter extends PlatformRouter {
11
- constructor(platform, configuration, routerOptions = {}) {
12
- var _a;
13
- super(platform);
14
- const options = Object.assign({
15
- mergeParams: true
16
- }, ((_a = configuration.express) === null || _a === void 0 ? void 0 : _a.router) || {}, routerOptions);
17
- this.rawRouter = this.raw = Express.Router(options);
18
- }
19
- statics(endpoint, options) {
20
- const { root, ...props } = options;
21
- this.use(endpoint, staticsMiddleware(root, props));
22
- return this;
23
- }
24
- };
25
- PlatformExpressRouter = __decorate([
26
- __param(1, Configuration()),
27
- __param(2, Inject(PLATFORM_ROUTER_OPTIONS)),
28
- __metadata("design:paramtypes", [PlatformHandler, Object, Object])
29
- ], PlatformExpressRouter);
30
- export { PlatformExpressRouter };
31
- //# sourceMappingURL=PlatformExpressRouter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformExpressRouter.js","sourceRoot":"","sources":["../../../src/services/PlatformExpressRouter.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,uBAAuB,EAAE,eAAe,EAAE,cAAc,EAAyB,MAAM,cAAc,CAAC;AAC9G,OAAO,EAAC,aAAa,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AAC/C,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAC,iBAAiB,EAAC,MAAM,kCAAkC,CAAC;AAQnE;;;GAGG;AACH,IAAa,qBAAqB,GAAlC,MAAa,qBAAsB,SAAQ,cAA8B;IACvE,YACE,QAAyB,EACR,aAA4B,EACZ,gBAAwC,EAAE;;QAE3E,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEhB,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAC3B;YACE,WAAW,EAAE,IAAI;SAClB,EACD,CAAA,MAAA,aAAa,CAAC,OAAO,0CAAE,MAAM,KAAI,EAAE,EACnC,aAAa,CACd,CAAC;QACF,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,CAAC,QAAgB,EAAE,OAA+B;QACvD,MAAM,EAAC,IAAI,EAAE,GAAG,KAAK,EAAC,GAAG,OAAO,CAAC;QAEjC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,iBAAiB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;QAEnD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAzBY,qBAAqB;IAG7B,WAAA,aAAa,EAAE,CAAA;IACf,WAAA,MAAM,CAAC,uBAAuB,CAAC,CAAA;qCAFtB,eAAe;GAFhB,qBAAqB,CAyBjC;SAzBY,qBAAqB","sourcesContent":["import {PLATFORM_ROUTER_OPTIONS, PlatformHandler, PlatformRouter, PlatformStaticsOptions} from \"@tsed/common\";\nimport {Configuration, Inject} from \"@tsed/di\";\nimport Express from \"express\";\nimport {RouterOptions} from \"express\";\nimport {staticsMiddleware} from \"../middlewares/staticsMiddleware\";\n\ndeclare global {\n namespace TsED {\n export interface Router extends Express.Router {}\n }\n}\n\n/**\n * @platform\n * @express\n */\nexport class PlatformExpressRouter extends PlatformRouter<Express.Router> {\n constructor(\n platform: PlatformHandler,\n @Configuration() configuration: Configuration,\n @Inject(PLATFORM_ROUTER_OPTIONS) routerOptions: Partial<RouterOptions> = {}\n ) {\n super(platform);\n\n const options = Object.assign(\n {\n mergeParams: true\n },\n configuration.express?.router || {},\n routerOptions\n );\n this.rawRouter = this.raw = Express.Router(options);\n }\n\n statics(endpoint: string, options: PlatformStaticsOptions) {\n const {root, ...props} = options;\n\n this.use(endpoint, staticsMiddleware(root, props));\n\n return this;\n }\n}\n"]}
@@ -1,6 +0,0 @@
1
- export * from "./PlatformExpressApplication";
2
- export * from "./PlatformExpressHandler";
3
- export * from "./PlatformExpressResponse";
4
- export * from "./PlatformExpressRequest";
5
- export * from "./PlatformExpressRouter";
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC","sourcesContent":["export * from \"./PlatformExpressApplication\";\nexport * from \"./PlatformExpressHandler\";\nexport * from \"./PlatformExpressResponse\";\nexport * from \"./PlatformExpressRequest\";\nexport * from \"./PlatformExpressRouter\";\n"]}
@@ -1,23 +0,0 @@
1
- /**
2
- * Specify the behavior of the router controller.
3
- *
4
- * ```typescript
5
- * @Controller("/")
6
- * @CaseSensitive(true)
7
- * class MyCtrl {
8
- *
9
- * }
10
- * ```
11
- *
12
- * Property | Description | Default
13
- * ---|---|---
14
- * CaseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.
15
- * MergeParams | Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child’s value take precedence. | false
16
- * Strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.
17
- *
18
- * @param caseSensitive
19
- * @returns {Function}
20
- * @decorator
21
- * @express
22
- */
23
- export declare function CaseSensitive(caseSensitive: boolean): Function;
@@ -1,4 +0,0 @@
1
- export * from "./routerSettings";
2
- export * from "./caseSensitive";
3
- export * from "./mergeParams";
4
- export * from "./strict";
@@ -1,23 +0,0 @@
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;