@tsed/platform-koa 7.0.0-beta.1 → 7.0.0-beta.4

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 (71) hide show
  1. package/lib/cjs/components/PlatformKoa.js +76 -20
  2. package/lib/cjs/components/PlatformKoa.js.map +1 -1
  3. package/lib/cjs/exports.js +7 -0
  4. package/lib/cjs/exports.js.map +1 -0
  5. package/lib/cjs/index.js +18 -12
  6. package/lib/cjs/index.js.map +1 -1
  7. package/lib/cjs/interfaces/PlatformKoaSettings.js.map +1 -1
  8. package/lib/cjs/interfaces/{index.js → interfaces.js} +2 -2
  9. package/lib/cjs/interfaces/interfaces.js.map +1 -0
  10. package/lib/cjs/middlewares/resourceNotFoundMiddleware.js +2 -2
  11. package/lib/cjs/middlewares/resourceNotFoundMiddleware.js.map +1 -1
  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/PlatformKoaRequest.js +7 -7
  16. package/lib/cjs/services/PlatformKoaRequest.js.map +1 -1
  17. package/lib/cjs/services/PlatformKoaResponse.js +4 -4
  18. package/lib/cjs/services/PlatformKoaResponse.js.map +1 -1
  19. package/lib/cjs/utils/multer.js +26 -1
  20. package/lib/cjs/utils/multer.js.map +1 -1
  21. package/lib/esm/components/PlatformKoa.js +73 -18
  22. package/lib/esm/components/PlatformKoa.js.map +1 -1
  23. package/lib/esm/decorators/caseSensitive.js +1 -1
  24. package/lib/esm/decorators/strict.js +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 +18 -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/middlewares/resourceNotFoundMiddleware.js +1 -1
  33. package/lib/esm/middlewares/resourceNotFoundMiddleware.js.map +1 -1
  34. package/lib/esm/package.json +3 -0
  35. package/lib/esm/services/PlatformKoaHandler.js +1 -1
  36. package/lib/esm/services/PlatformKoaResponse.js +1 -1
  37. package/lib/esm/services/PlatformKoaResponse.js.map +1 -1
  38. package/lib/esm/utils/multer.js +3 -1
  39. package/lib/esm/utils/multer.js.map +1 -1
  40. package/lib/types/components/PlatformKoa.d.ts +35 -13
  41. package/lib/types/exports.d.ts +1 -0
  42. package/lib/types/index.d.ts +17 -3
  43. package/lib/types/interfaces/PlatformKoaSettings.d.ts +10 -3
  44. package/lib/types/interfaces/{index.d.ts → interfaces.d.ts} +0 -0
  45. package/lib/types/services/PlatformKoaResponse.d.ts +1 -1
  46. package/package.json +51 -26
  47. package/readme.md +0 -2
  48. package/tsconfig.compile.esm.json +1 -12
  49. package/lib/cjs/decorators/index.js +0 -9
  50. package/lib/cjs/decorators/index.js.map +0 -1
  51. package/lib/cjs/interfaces/index.js.map +0 -1
  52. package/lib/cjs/services/PlatformKoaApplication.js +0 -32
  53. package/lib/cjs/services/PlatformKoaApplication.js.map +0 -1
  54. package/lib/cjs/services/PlatformKoaRouter.js +0 -45
  55. package/lib/cjs/services/PlatformKoaRouter.js.map +0 -1
  56. package/lib/cjs/services/index.js +0 -9
  57. package/lib/cjs/services/index.js.map +0 -1
  58. package/lib/esm/decorators/index.js +0 -6
  59. package/lib/esm/decorators/index.js.map +0 -1
  60. package/lib/esm/interfaces/index.js +0 -2
  61. package/lib/esm/interfaces/index.js.map +0 -1
  62. package/lib/esm/services/PlatformKoaApplication.js +0 -29
  63. package/lib/esm/services/PlatformKoaApplication.js.map +0 -1
  64. package/lib/esm/services/PlatformKoaRouter.js +0 -42
  65. package/lib/esm/services/PlatformKoaRouter.js.map +0 -1
  66. package/lib/esm/services/index.js +0 -6
  67. package/lib/esm/services/index.js.map +0 -1
  68. package/lib/types/decorators/index.d.ts +0 -5
  69. package/lib/types/services/PlatformKoaApplication.d.ts +0 -22
  70. package/lib/types/services/PlatformKoaRouter.d.ts +0 -22
  71. package/lib/types/services/index.d.ts +0 -5
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PlatformKoaRouter = void 0;
4
- const tslib_1 = require("tslib");
5
- const router_1 = (0, tslib_1.__importDefault)(require("@koa/router"));
6
- const common_1 = require("@tsed/common");
7
- const di_1 = require("@tsed/di");
8
- const staticsMiddleware_1 = require("../middlewares/staticsMiddleware");
9
- const multer_1 = require("../utils/multer");
10
- // @ts-ignore
11
- router_1.default.prototype.$$match = router_1.default.prototype.match;
12
- router_1.default.prototype.match = function match(...args) {
13
- const matched = this.$$match(...args);
14
- if (matched) {
15
- if (matched.path.length) {
16
- matched.route = true;
17
- }
18
- }
19
- return matched;
20
- };
21
- let PlatformKoaRouter = class PlatformKoaRouter extends common_1.PlatformRouter {
22
- constructor(platform, configuration, routerOptions) {
23
- var _a;
24
- super(platform);
25
- const options = Object.assign({}, ((_a = configuration.koa) === null || _a === void 0 ? void 0 : _a.router) || {}, routerOptions);
26
- this.rawRouter = new router_1.default(options);
27
- }
28
- callback() {
29
- return [this.getRouter().routes(), this.getRouter().allowedMethods()];
30
- }
31
- multer(options) {
32
- return (0, multer_1.getMulter)(options);
33
- }
34
- statics(path, options) {
35
- this.rawRouter.use(path, (0, staticsMiddleware_1.staticsMiddleware)(options));
36
- return this;
37
- }
38
- };
39
- PlatformKoaRouter = (0, tslib_1.__decorate)([
40
- (0, tslib_1.__param)(1, (0, di_1.Configuration)()),
41
- (0, tslib_1.__param)(2, (0, di_1.Inject)(common_1.PLATFORM_ROUTER_OPTIONS)),
42
- (0, tslib_1.__metadata)("design:paramtypes", [common_1.PlatformHandler, Object, Object])
43
- ], PlatformKoaRouter);
44
- exports.PlatformKoaRouter = PlatformKoaRouter;
45
- //# sourceMappingURL=PlatformKoaRouter.js.map
@@ -1 +0,0 @@
1
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AAC,IAAI,EAAE,IAAA,qCAAiB,EAAC,OAAO,CAAQ,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAzBY,iBAAiB;IAGzB,wBAAA,IAAA,kBAAa,GAAE,CAAA;IACf,wBAAA,IAAA,WAAM,EAAC,gCAAuB,CAAC,CAAA;kDAFtB,wBAAe;GAFhB,iBAAiB,CAyB7B;AAzBY,8CAAiB","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,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("./PlatformKoaApplication"), exports);
5
- (0, tslib_1.__exportStar)(require("./PlatformKoaHandler"), exports);
6
- (0, tslib_1.__exportStar)(require("./PlatformKoaRouter"), exports);
7
- (0, tslib_1.__exportStar)(require("./PlatformKoaRequest"), exports);
8
- (0, tslib_1.__exportStar)(require("./PlatformKoaResponse"), exports);
9
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":";;;AAAA,wEAAyC;AACzC,oEAAqC;AACrC,mEAAoC;AACpC,oEAAqC;AACrC,qEAAsC","sourcesContent":["export * from \"./PlatformKoaApplication\";\nexport * from \"./PlatformKoaHandler\";\nexport * from \"./PlatformKoaRouter\";\nexport * from \"./PlatformKoaRequest\";\nexport * from \"./PlatformKoaResponse\";\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,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,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,KAA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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,5 +0,0 @@
1
- export * from "./routerSettings";
2
- export * from "./caseSensitive";
3
- export * from "./strict";
4
- export * from "./state";
5
- export * from "./ctx";
@@ -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";