@tsed/platform-koa 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 (94) hide show
  1. package/coverage.json +6 -0
  2. package/jest.config.js +9 -0
  3. package/lib/cjs/components/PlatformKoa.js +121 -45
  4. package/lib/cjs/components/PlatformKoa.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 +14 -12
  8. package/lib/cjs/index.js.map +1 -1
  9. package/lib/cjs/interfaces/PlatformKoaSettings.js.map +1 -1
  10. package/lib/cjs/interfaces/{index.js → interfaces.js} +2 -2
  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/cjs/services/PlatformKoaHandler.js +6 -48
  16. package/lib/cjs/services/PlatformKoaHandler.js.map +1 -1
  17. package/lib/cjs/services/PlatformKoaRequest.js +8 -18
  18. package/lib/cjs/services/PlatformKoaRequest.js.map +1 -1
  19. package/lib/cjs/services/PlatformKoaResponse.js +5 -9
  20. package/lib/cjs/services/PlatformKoaResponse.js.map +1 -1
  21. package/lib/cjs/utils/multer.js +26 -1
  22. package/lib/cjs/utils/multer.js.map +1 -1
  23. package/lib/esm/components/PlatformKoa.js +121 -46
  24. package/lib/esm/components/PlatformKoa.js.map +1 -1
  25. package/lib/esm/exports.js +5 -0
  26. package/lib/esm/exports.js.map +1 -0
  27. package/lib/esm/index.js +14 -12
  28. package/lib/esm/index.js.map +1 -1
  29. package/lib/esm/interfaces/PlatformKoaSettings.js.map +1 -1
  30. package/lib/esm/interfaces/interfaces.js +2 -0
  31. package/lib/esm/interfaces/interfaces.js.map +1 -0
  32. package/lib/esm/package.json +3 -0
  33. package/lib/esm/services/PlatformKoaHandler.js +8 -50
  34. package/lib/esm/services/PlatformKoaHandler.js.map +1 -1
  35. package/lib/esm/services/PlatformKoaRequest.js +8 -18
  36. package/lib/esm/services/PlatformKoaRequest.js.map +1 -1
  37. package/lib/esm/services/PlatformKoaResponse.js +4 -9
  38. package/lib/esm/services/PlatformKoaResponse.js.map +1 -1
  39. package/lib/esm/utils/multer.js +3 -1
  40. package/lib/esm/utils/multer.js.map +1 -1
  41. package/lib/types/components/PlatformKoa.d.ts +31 -16
  42. package/lib/types/exports.d.ts +1 -0
  43. package/lib/types/index.d.ts +13 -3
  44. package/lib/types/interfaces/PlatformKoaSettings.d.ts +10 -3
  45. package/lib/types/interfaces/{index.d.ts → interfaces.d.ts} +0 -0
  46. package/lib/types/services/PlatformKoaHandler.d.ts +2 -7
  47. package/lib/types/services/PlatformKoaRequest.d.ts +3 -6
  48. package/lib/types/services/PlatformKoaResponse.d.ts +3 -4
  49. package/package.json +62 -29
  50. package/readme.md +3 -4
  51. package/tsconfig.compile.esm.json +1 -12
  52. package/lib/cjs/decorators/caseSensitive.js +0 -30
  53. package/lib/cjs/decorators/caseSensitive.js.map +0 -1
  54. package/lib/cjs/decorators/index.js +0 -9
  55. package/lib/cjs/decorators/index.js.map +0 -1
  56. package/lib/cjs/decorators/routerSettings.js +0 -31
  57. package/lib/cjs/decorators/routerSettings.js.map +0 -1
  58. package/lib/cjs/decorators/strict.js +0 -31
  59. package/lib/cjs/decorators/strict.js.map +0 -1
  60. package/lib/cjs/interfaces/index.js.map +0 -1
  61. package/lib/cjs/middlewares/resourceNotFoundMiddleware.js +0 -20
  62. package/lib/cjs/middlewares/resourceNotFoundMiddleware.js.map +0 -1
  63. package/lib/cjs/services/PlatformKoaApplication.js +0 -32
  64. package/lib/cjs/services/PlatformKoaApplication.js.map +0 -1
  65. package/lib/cjs/services/PlatformKoaRouter.js +0 -45
  66. package/lib/cjs/services/PlatformKoaRouter.js.map +0 -1
  67. package/lib/cjs/services/index.js +0 -9
  68. package/lib/cjs/services/index.js.map +0 -1
  69. package/lib/esm/decorators/caseSensitive.js +0 -26
  70. package/lib/esm/decorators/caseSensitive.js.map +0 -1
  71. package/lib/esm/decorators/index.js +0 -6
  72. package/lib/esm/decorators/index.js.map +0 -1
  73. package/lib/esm/decorators/routerSettings.js +0 -27
  74. package/lib/esm/decorators/routerSettings.js.map +0 -1
  75. package/lib/esm/decorators/strict.js +0 -27
  76. package/lib/esm/decorators/strict.js.map +0 -1
  77. package/lib/esm/interfaces/index.js +0 -2
  78. package/lib/esm/interfaces/index.js.map +0 -1
  79. package/lib/esm/middlewares/resourceNotFoundMiddleware.js +0 -16
  80. package/lib/esm/middlewares/resourceNotFoundMiddleware.js.map +0 -1
  81. package/lib/esm/services/PlatformKoaApplication.js +0 -29
  82. package/lib/esm/services/PlatformKoaApplication.js.map +0 -1
  83. package/lib/esm/services/PlatformKoaRouter.js +0 -42
  84. package/lib/esm/services/PlatformKoaRouter.js.map +0 -1
  85. package/lib/esm/services/index.js +0 -6
  86. package/lib/esm/services/index.js.map +0 -1
  87. package/lib/types/decorators/caseSensitive.d.ts +0 -22
  88. package/lib/types/decorators/index.d.ts +0 -5
  89. package/lib/types/decorators/routerSettings.d.ts +0 -24
  90. package/lib/types/decorators/strict.d.ts +0 -23
  91. package/lib/types/middlewares/resourceNotFoundMiddleware.d.ts +0 -6
  92. package/lib/types/services/PlatformKoaApplication.d.ts +0 -22
  93. package/lib/types/services/PlatformKoaRouter.d.ts +0 -22
  94. package/lib/types/services/index.d.ts +0 -5
@@ -1,26 +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
- * Strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.
17
- *
18
- * @returns {Function}
19
- * @decorator
20
- * @koa
21
- * @param sensitive
22
- */
23
- export function CaseSensitive(sensitive) {
24
- return RouterSettings({ sensitive });
25
- }
26
- //# 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;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,aAAa,CAAC,SAAkB;IAC9C,OAAO,cAAc,CAAC,EAAC,SAAS,EAAC,CAAC,CAAC;AACrC,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 * Strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.\n *\n * @returns {Function}\n * @decorator\n * @koa\n * @param sensitive\n */\nexport function CaseSensitive(sensitive: boolean) {\n return RouterSettings({sensitive});\n}\n"]}
@@ -1,6 +0,0 @@
1
- export * from "./routerSettings";
2
- export * from "./caseSensitive";
3
- export * from "./strict";
4
- export * from "./state";
5
- export * from "./ctx";
6
- //# 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,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC","sourcesContent":["export * from \"./routerSettings\";\nexport * from \"./caseSensitive\";\nexport * from \"./strict\";\nexport * from \"./state\";\nexport * from \"./ctx\";\n"]}
@@ -1,27 +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({sensitive: true})
9
- * class MyCtrl {
10
- *
11
- * }
12
- * ```
13
- *
14
- * Property | Description | Default
15
- * ---|---|---
16
- * sensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.
17
- * strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.
18
- *
19
- * @returns {(target:any)=>void}
20
- * @decorator
21
- * @param routerOptions
22
- * @koa
23
- */
24
- export function RouterSettings(routerOptions) {
25
- return StoreMerge(ROUTER_OPTIONS, routerOptions);
26
- }
27
- //# 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;;;;;;;;;;;;;;;;;;;;GAoBG;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 \"@koa/router\";\n\n/**\n * Specify the behavior of the router controller.\n *\n * ```typescript\n * @Controller(\"/\")\n * @RouterSettings({sensitive: true})\n * class MyCtrl {\n *\n * }\n * ```\n *\n * Property | Description | Default\n * ---|---|---\n * sensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.\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 * @koa\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
- * @koa
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 * @koa\n */\nexport function Strict(strict: boolean) {\n return RouterSettings({strict});\n}\n"]}
@@ -1,2 +0,0 @@
1
- export * from "./PlatformKoaSettings";
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":"AAGA,cAAc,uBAAuB,CAAC","sourcesContent":["import Koa from \"koa\";\nimport {PlatformKoaSettings} from \"./PlatformKoaSettings\";\n\nexport * from \"./PlatformKoaSettings\";\n\ndeclare global {\n namespace TsED {\n export interface Configuration {\n /**\n * Configuration related to Koa platform application.\n */\n koa: PlatformKoaSettings;\n }\n\n export interface NextFunction extends Koa.Next {}\n }\n}\n"]}
@@ -1,16 +0,0 @@
1
- import { PlatformExceptions } from "@tsed/common";
2
- /**
3
- * @ignore
4
- * @param ctx
5
- * @param next
6
- */
7
- export async function resourceNotFoundMiddleware(ctx, next) {
8
- var _a;
9
- const $ctx = ctx.request.$ctx;
10
- await next();
11
- const status = ctx.status || 404;
12
- if (status === 404 && !$ctx.isDone()) {
13
- (_a = $ctx.injector.get(PlatformExceptions)) === null || _a === void 0 ? void 0 : _a.resourceNotFound($ctx);
14
- }
15
- }
16
- //# sourceMappingURL=resourceNotFoundMiddleware.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resourceNotFoundMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/resourceNotFoundMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAEjE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,GAAQ,EAAE,IAAS;;IAClE,MAAM,IAAI,GAAoB,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC;IAC/C,MAAM,IAAI,EAAE,CAAC;IACb,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC;IAEjC,IAAI,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE;QACpC,MAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAqB,kBAAkB,CAAC,0CAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC;KACnF;AACH,CAAC","sourcesContent":["import {PlatformContext, PlatformExceptions} from \"@tsed/common\";\n\n/**\n * @ignore\n * @param ctx\n * @param next\n */\nexport async function resourceNotFoundMiddleware(ctx: any, next: any) {\n const $ctx: PlatformContext = ctx.request.$ctx;\n await next();\n const status = ctx.status || 404;\n\n if (status === 404 && !$ctx.isDone()) {\n $ctx.injector.get<PlatformExceptions>(PlatformExceptions)?.resourceNotFound($ctx);\n }\n}\n"]}
@@ -1,29 +0,0 @@
1
- import { __decorate, __metadata, __param } from "tslib";
2
- import { Configuration, Inject, PlatformHandler } from "@tsed/common";
3
- import Koa from "koa";
4
- import { PlatformKoaRouter } from "./PlatformKoaRouter";
5
- const koaQs = require("koa-qs");
6
- /**
7
- * @platform
8
- * @express
9
- */
10
- let PlatformKoaApplication = class PlatformKoaApplication extends PlatformKoaRouter {
11
- constructor(platformHandler, configuration) {
12
- super(platformHandler, configuration, {});
13
- this.rawApp = configuration.get("koa.app") || new Koa();
14
- koaQs(this.rawApp, "extended");
15
- }
16
- getApp() {
17
- return this.rawApp;
18
- }
19
- callback() {
20
- return this.getApp().callback();
21
- }
22
- };
23
- PlatformKoaApplication = __decorate([
24
- __param(0, Inject()),
25
- __param(1, Configuration()),
26
- __metadata("design:paramtypes", [PlatformHandler, Object])
27
- ], PlatformKoaApplication);
28
- export { PlatformKoaApplication };
29
- //# sourceMappingURL=PlatformKoaApplication.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformKoaApplication.js","sourceRoot":"","sources":["../../../src/services/PlatformKoaApplication.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,aAAa,EAAE,MAAM,EAAuB,eAAe,EAAC,MAAM,cAAc,CAAC;AACzF,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAEtD,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAQhC;;;GAGG;AACH,IAAa,sBAAsB,GAAnC,MAAa,sBAAuB,SAAQ,iBAAiB;IAI3D,YAAsB,eAAgC,EAAmB,aAA4B;QACnG,KAAK,CAAC,eAAe,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC;QAE1C,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,IAAI,GAAG,EAAE,CAAC;QACxD,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACjC,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;IAClC,CAAC;CACF,CAAA;AAlBY,sBAAsB;IAIpB,WAAA,MAAM,EAAE,CAAA;IAAoC,WAAA,aAAa,EAAE,CAAA;qCAAjC,eAAe;GAJ3C,sBAAsB,CAkBlC;SAlBY,sBAAsB","sourcesContent":["import KoaRouter from \"@koa/router\";\nimport {Configuration, Inject, PlatformApplication, PlatformHandler} from \"@tsed/common\";\nimport Koa from \"koa\";\nimport {PlatformKoaRouter} from \"./PlatformKoaRouter\";\n\nconst koaQs = require(\"koa-qs\");\n\ndeclare global {\n namespace TsED {\n export interface Application extends Koa {}\n }\n}\n\n/**\n * @platform\n * @express\n */\nexport class PlatformKoaApplication extends PlatformKoaRouter implements PlatformApplication<Koa, KoaRouter> {\n app: Koa;\n rawApp: Koa;\n\n constructor(@Inject() platformHandler: PlatformHandler, @Configuration() configuration: Configuration) {\n super(platformHandler, configuration, {});\n\n this.rawApp = configuration.get(\"koa.app\") || new Koa();\n koaQs(this.rawApp, \"extended\");\n }\n\n getApp(): Koa {\n return this.rawApp;\n }\n\n callback(): any {\n return this.getApp().callback();\n }\n}\n"]}
@@ -1,42 +0,0 @@
1
- import { __decorate, __metadata, __param } from "tslib";
2
- import KoaRouter from "@koa/router";
3
- import { PLATFORM_ROUTER_OPTIONS, PlatformHandler, PlatformRouter } from "@tsed/common";
4
- import { Configuration, Inject } from "@tsed/di";
5
- import { staticsMiddleware } from "../middlewares/staticsMiddleware";
6
- import { getMulter } from "../utils/multer";
7
- // @ts-ignore
8
- KoaRouter.prototype.$$match = KoaRouter.prototype.match;
9
- KoaRouter.prototype.match = function match(...args) {
10
- const matched = this.$$match(...args);
11
- if (matched) {
12
- if (matched.path.length) {
13
- matched.route = true;
14
- }
15
- }
16
- return matched;
17
- };
18
- let PlatformKoaRouter = class PlatformKoaRouter extends PlatformRouter {
19
- constructor(platform, configuration, routerOptions) {
20
- var _a;
21
- super(platform);
22
- const options = Object.assign({}, ((_a = configuration.koa) === null || _a === void 0 ? void 0 : _a.router) || {}, routerOptions);
23
- this.rawRouter = new KoaRouter(options);
24
- }
25
- callback() {
26
- return [this.getRouter().routes(), this.getRouter().allowedMethods()];
27
- }
28
- multer(options) {
29
- return getMulter(options);
30
- }
31
- statics(path, options) {
32
- this.rawRouter.use(path, staticsMiddleware(options));
33
- return this;
34
- }
35
- };
36
- PlatformKoaRouter = __decorate([
37
- __param(1, Configuration()),
38
- __param(2, Inject(PLATFORM_ROUTER_OPTIONS)),
39
- __metadata("design:paramtypes", [PlatformHandler, Object, Object])
40
- ], PlatformKoaRouter);
41
- export { PlatformKoaRouter };
42
- //# sourceMappingURL=PlatformKoaRouter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformKoaRouter.js","sourceRoot":"","sources":["../../../src/services/PlatformKoaRouter.ts"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC,OAAO,EACL,uBAAuB,EACvB,eAAe,EAGf,cAAc,EAEf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,aAAa,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AAE/C,OAAO,EAAC,iBAAiB,EAAC,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAY1C,aAAa;AACb,SAAS,CAAC,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC;AACxD,SAAS,CAAC,SAAS,CAAC,KAAK,GAAG,SAAS,KAAK,CAAC,GAAG,IAAW;IACvD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;IACtC,IAAI,OAAO,EAAE;QACX,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE;YACvB,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;SACtB;KACF;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,cAAyB;IAC9D,YACE,QAAyB,EACR,aAA4B,EACZ,aAAkB;;QAEnD,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEhB,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,CAAA,MAAA,aAAa,CAAC,GAAG,0CAAE,MAAM,KAAI,EAAE,EAAE,aAAa,CAAC,CAAC;QAClF,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,OAAO,CAAQ,CAAC;IACjD,CAAC;IAED,QAAQ;QACN,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,CAAC,OAA+B;QACpC,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,CAAC,IAAY,EAAE,OAA+B;QACnD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAQ,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAzBY,iBAAiB;IAGzB,WAAA,aAAa,EAAE,CAAA;IACf,WAAA,MAAM,CAAC,uBAAuB,CAAC,CAAA;qCAFtB,eAAe;GAFhB,iBAAiB,CAyB7B;SAzBY,iBAAiB","sourcesContent":["import KoaRouter from \"@koa/router\";\nimport {RouterOptions as KoaRouterOptions} from \"@koa/router\";\n\nimport {\n PLATFORM_ROUTER_OPTIONS,\n PlatformHandler,\n PlatformMulter,\n PlatformMulterSettings,\n PlatformRouter,\n PlatformStaticsOptions\n} from \"@tsed/common\";\nimport {Configuration, Inject} from \"@tsed/di\";\nimport send from \"koa-send\";\nimport {staticsMiddleware} from \"../middlewares/staticsMiddleware\";\nimport {getMulter} from \"../utils/multer\";\n\ndeclare global {\n namespace TsED {\n export interface Router extends KoaRouter {}\n\n export interface RouterOptions extends KoaRouterOptions {}\n\n export interface StaticsOptions extends send.SendOptions {}\n }\n}\n\n// @ts-ignore\nKoaRouter.prototype.$$match = KoaRouter.prototype.match;\nKoaRouter.prototype.match = function match(...args: any[]) {\n const matched = this.$$match(...args);\n if (matched) {\n if (matched.path.length) {\n matched.route = true;\n }\n }\n\n return matched;\n};\n\nexport class PlatformKoaRouter extends PlatformRouter<KoaRouter> {\n constructor(\n platform: PlatformHandler,\n @Configuration() configuration: Configuration,\n @Inject(PLATFORM_ROUTER_OPTIONS) routerOptions: any\n ) {\n super(platform);\n\n const options = Object.assign({}, configuration.koa?.router || {}, routerOptions);\n this.rawRouter = new KoaRouter(options) as any;\n }\n\n callback() {\n return [this.getRouter().routes(), this.getRouter().allowedMethods()];\n }\n\n multer(options: PlatformMulterSettings): PlatformMulter {\n return getMulter(options);\n }\n\n statics(path: string, options: PlatformStaticsOptions) {\n this.rawRouter.use(path, staticsMiddleware(options) as any);\n\n return this;\n }\n}\n"]}
@@ -1,6 +0,0 @@
1
- export * from "./PlatformKoaApplication";
2
- export * from "./PlatformKoaHandler";
3
- export * from "./PlatformKoaRouter";
4
- export * from "./PlatformKoaRequest";
5
- export * from "./PlatformKoaResponse";
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC","sourcesContent":["export * from \"./PlatformKoaApplication\";\nexport * from \"./PlatformKoaHandler\";\nexport * from \"./PlatformKoaRouter\";\nexport * from \"./PlatformKoaRequest\";\nexport * from \"./PlatformKoaResponse\";\n"]}
@@ -1,22 +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
- * Strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.
16
- *
17
- * @returns {Function}
18
- * @decorator
19
- * @koa
20
- * @param sensitive
21
- */
22
- export declare function CaseSensitive(sensitive: boolean): Function;
@@ -1,5 +0,0 @@
1
- export * from "./routerSettings";
2
- export * from "./caseSensitive";
3
- export * from "./strict";
4
- export * from "./state";
5
- export * from "./ctx";
@@ -1,24 +0,0 @@
1
- /// <reference types="koa__router" />
2
- import { RouterOptions } from "@koa/router";
3
- /**
4
- * Specify the behavior of the router controller.
5
- *
6
- * ```typescript
7
- * @Controller("/")
8
- * @RouterSettings({sensitive: true})
9
- * class MyCtrl {
10
- *
11
- * }
12
- * ```
13
- *
14
- * Property | Description | Default
15
- * ---|---|---
16
- * sensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.
17
- * strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.
18
- *
19
- * @returns {(target:any)=>void}
20
- * @decorator
21
- * @param routerOptions
22
- * @koa
23
- */
24
- export declare function RouterSettings(routerOptions: RouterOptions): Function;
@@ -1,23 +0,0 @@
1
- /**
2
- * Specify the behavior of the router controller.
3
- *
4
- * ```typescript
5
- * @Controller("/")
6
- * @Strict(true)
7
- * class MyCtrl {
8
- *
9
- * }
10
- * ```
11
- *
12
- * Property | Description | Default
13
- * ---|---|---
14
- * CaseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.
15
- * MergeParams | Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child’s value take precedence. | false
16
- * Strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.
17
- *
18
- * @param strict
19
- * @returns {Function}
20
- * @decorator
21
- * @koa
22
- */
23
- export declare function Strict(strict: boolean): Function;
@@ -1,6 +0,0 @@
1
- /**
2
- * @ignore
3
- * @param ctx
4
- * @param next
5
- */
6
- export declare function resourceNotFoundMiddleware(ctx: any, next: any): Promise<void>;
@@ -1,22 +0,0 @@
1
- /// <reference types="koa__router" />
2
- import KoaRouter from "@koa/router";
3
- import { Configuration, PlatformApplication, PlatformHandler } from "@tsed/common";
4
- import Koa from "koa";
5
- import { PlatformKoaRouter } from "./PlatformKoaRouter";
6
- declare global {
7
- namespace TsED {
8
- interface Application extends Koa {
9
- }
10
- }
11
- }
12
- /**
13
- * @platform
14
- * @express
15
- */
16
- export declare class PlatformKoaApplication extends PlatformKoaRouter implements PlatformApplication<Koa, KoaRouter> {
17
- app: Koa;
18
- rawApp: Koa;
19
- constructor(platformHandler: PlatformHandler, configuration: Configuration);
20
- getApp(): Koa;
21
- callback(): any;
22
- }
@@ -1,22 +0,0 @@
1
- /// <reference types="koa__router" />
2
- import KoaRouter from "@koa/router";
3
- import { RouterOptions as KoaRouterOptions } from "@koa/router";
4
- import { PlatformHandler, PlatformMulter, PlatformMulterSettings, PlatformRouter, PlatformStaticsOptions } from "@tsed/common";
5
- import { Configuration } from "@tsed/di";
6
- import send from "koa-send";
7
- declare global {
8
- namespace TsED {
9
- interface Router extends KoaRouter {
10
- }
11
- interface RouterOptions extends KoaRouterOptions {
12
- }
13
- interface StaticsOptions extends send.SendOptions {
14
- }
15
- }
16
- }
17
- export declare class PlatformKoaRouter extends PlatformRouter<KoaRouter> {
18
- constructor(platform: PlatformHandler, configuration: Configuration, routerOptions: any);
19
- callback(): KoaRouter.Middleware<any, {}>[];
20
- multer(options: PlatformMulterSettings): PlatformMulter;
21
- statics(path: string, options: PlatformStaticsOptions): this;
22
- }
@@ -1,5 +0,0 @@
1
- export * from "./PlatformKoaApplication";
2
- export * from "./PlatformKoaHandler";
3
- export * from "./PlatformKoaRouter";
4
- export * from "./PlatformKoaRequest";
5
- export * from "./PlatformKoaResponse";