@tsed/platform-koa 6.89.0 → 6.90.0

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.
@@ -1,6 +1,6 @@
1
1
  /// <reference types="koa__router" />
2
2
  import KoaRouter from "@koa/router";
3
- import { PlatformApplication, PlatformBuilder, PlatformBuilderOptions, PlatformHandler, PlatformRequest, PlatformResponse, PlatformRouter } from "@tsed/common";
3
+ import { PlatformAdapter, PlatformApplication, PlatformBuilder, PlatformHandler, PlatformRequest, PlatformResponse, PlatformRouter } from "@tsed/common";
4
4
  import { Type } from "@tsed/core";
5
5
  import Koa from "koa";
6
6
  import { PlatformKoaApplication, PlatformKoaHandler, PlatformKoaRequest, PlatformKoaResponse, PlatformKoaRouter } from "../services";
@@ -8,8 +8,9 @@ import { PlatformKoaApplication, PlatformKoaHandler, PlatformKoaRequest, Platfor
8
8
  * @platform
9
9
  * @koa
10
10
  */
11
- export declare class PlatformKoa extends PlatformBuilder<Koa, KoaRouter> {
12
- static providers: ({
11
+ export declare class PlatformKoa implements PlatformAdapter<Koa, KoaRouter> {
12
+ private platform;
13
+ readonly providers: ({
13
14
  provide: typeof PlatformResponse;
14
15
  useClass: typeof PlatformKoaResponse;
15
16
  } | {
@@ -25,14 +26,20 @@ export declare class PlatformKoa extends PlatformBuilder<Koa, KoaRouter> {
25
26
  provide: typeof PlatformApplication;
26
27
  useClass: typeof PlatformKoaApplication;
27
28
  })[];
28
- constructor(options: PlatformBuilderOptions);
29
+ constructor(platform: PlatformBuilder<Koa, KoaRouter>);
29
30
  /**
30
31
  * Create new serverless application. In this mode, the component scan are disabled.
31
32
  * @param module
32
33
  * @param settings
33
34
  */
34
- static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformKoa;
35
- static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformKoa>;
36
- protected useRouter(): this;
37
- protected useContext(): this;
35
+ static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<Koa<Koa.DefaultState, Koa.DefaultContext>, KoaRouter<any, {}>>;
36
+ /**
37
+ * Bootstrap a server application
38
+ * @param module
39
+ * @param settings
40
+ */
41
+ static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<Koa<Koa.DefaultState, Koa.DefaultContext>, KoaRouter<any, {}>>>;
42
+ onInit(): void;
43
+ useRouter(): this;
44
+ useContext(): this;
38
45
  }
@@ -8,15 +8,31 @@ const services_1 = require("../services");
8
8
  * @platform
9
9
  * @koa
10
10
  */
11
- class PlatformKoa extends common_1.PlatformBuilder {
12
- constructor(options) {
13
- super(options);
14
- const listener = (error, ctx) => {
15
- var _a;
16
- (_a = this.injector.get(common_1.PlatformExceptions)) === null || _a === void 0 ? void 0 : _a.catch(error, ctx.request.$ctx);
17
- };
18
- this.app.getApp().silent = true;
19
- this.app.getApp().on("error", listener);
11
+ class PlatformKoa {
12
+ constructor(platform) {
13
+ this.platform = platform;
14
+ this.providers = [
15
+ {
16
+ provide: common_1.PlatformResponse,
17
+ useClass: services_1.PlatformKoaResponse
18
+ },
19
+ {
20
+ provide: common_1.PlatformRequest,
21
+ useClass: services_1.PlatformKoaRequest
22
+ },
23
+ {
24
+ provide: common_1.PlatformHandler,
25
+ useClass: services_1.PlatformKoaHandler
26
+ },
27
+ {
28
+ provide: common_1.PlatformRouter,
29
+ useClass: services_1.PlatformKoaRouter
30
+ },
31
+ {
32
+ provide: common_1.PlatformApplication,
33
+ useClass: services_1.PlatformKoaApplication
34
+ }
35
+ ];
20
36
  }
21
37
  /**
22
38
  * Create new serverless application. In this mode, the component scan are disabled.
@@ -24,24 +40,41 @@ class PlatformKoa extends common_1.PlatformBuilder {
24
40
  * @param settings
25
41
  */
26
42
  static create(module, settings = {}) {
27
- return this.build(PlatformKoa, module, {
28
- httpsPort: false,
29
- httpPort: false,
43
+ return common_1.PlatformBuilder.create(module, {
30
44
  ...settings,
31
- disableComponentsScan: true
45
+ adapter: PlatformKoa
32
46
  });
33
47
  }
48
+ /**
49
+ * Bootstrap a server application
50
+ * @param module
51
+ * @param settings
52
+ */
34
53
  static async bootstrap(module, settings = {}) {
35
- return this.build(PlatformKoa, module, settings).bootstrap();
54
+ return common_1.PlatformBuilder.bootstrap(module, {
55
+ ...settings,
56
+ adapter: PlatformKoa
57
+ });
58
+ }
59
+ onInit() {
60
+ const { injector, app } = this.platform;
61
+ const listener = (error, ctx) => {
62
+ var _a;
63
+ (_a = injector.get(common_1.PlatformExceptions)) === null || _a === void 0 ? void 0 : _a.catch(error, ctx.request.$ctx);
64
+ };
65
+ app.getApp().silent = true;
66
+ app.getApp().on("error", listener);
36
67
  }
37
68
  useRouter() {
38
- this.app.getApp().use(resourceNotFoundMiddleware_1.resourceNotFoundMiddleware).use(this.app.getRouter().routes()).use(this.app.getRouter().allowedMethods());
69
+ const { app } = this.platform;
70
+ app.getApp().use(resourceNotFoundMiddleware_1.resourceNotFoundMiddleware).use(app.getRouter().routes()).use(app.getRouter().allowedMethods());
39
71
  return this;
40
72
  }
41
73
  useContext() {
42
- this.logger.info("Mount app context");
43
- const invoke = (0, common_1.createContext)(this.injector);
44
- this.app.getApp().use(async (ctx, next) => {
74
+ const { injector, app, logger } = this.platform;
75
+ logger.info("Mount app context");
76
+ const invoke = (0, common_1.createContext)(injector);
77
+ app.getApp().use(async (ctx, next) => {
45
78
  await invoke({
46
79
  request: ctx.request,
47
80
  response: ctx.response,
@@ -53,26 +86,4 @@ class PlatformKoa extends common_1.PlatformBuilder {
53
86
  }
54
87
  }
55
88
  exports.PlatformKoa = PlatformKoa;
56
- PlatformKoa.providers = [
57
- {
58
- provide: common_1.PlatformResponse,
59
- useClass: services_1.PlatformKoaResponse
60
- },
61
- {
62
- provide: common_1.PlatformRequest,
63
- useClass: services_1.PlatformKoaRequest
64
- },
65
- {
66
- provide: common_1.PlatformHandler,
67
- useClass: services_1.PlatformKoaHandler
68
- },
69
- {
70
- provide: common_1.PlatformRouter,
71
- useClass: services_1.PlatformKoaRouter
72
- },
73
- {
74
- provide: common_1.PlatformApplication,
75
- useClass: services_1.PlatformKoaApplication
76
- }
77
- ];
78
89
  //# sourceMappingURL=PlatformKoa.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformKoa.js","sourceRoot":"","sources":["../../../src/components/PlatformKoa.ts"],"names":[],"mappings":";;;AACA,yCAUsB;AAGtB,0FAAqF;AACrF,0CAAmI;AAEnI;;;GAGG;AACH,MAAa,WAAY,SAAQ,wBAA+B;IAwB9D,YAAY,OAA+B;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,MAAM,QAAQ,GAAQ,CAAC,KAAU,EAAE,GAAgB,EAAE,EAAE;;YACrD,MAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAqB,2BAAkB,CAAC,0CAAE,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC5F,CAAC,CAAC;QAEF,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC;QAChC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,MAAiB,EAAE,WAAwC,EAAE;QACzE,OAAO,IAAI,CAAC,KAAK,CAAc,WAAW,EAAE,MAAM,EAAE;YAClD,SAAS,EAAE,KAAK;YAChB,QAAQ,EAAE,KAAK;YACf,GAAG,QAAQ;YACX,qBAAqB,EAAE,IAAI;SAC5B,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,MAAiB,EAAE,WAAwC,EAAE;QAClF,OAAO,IAAI,CAAC,KAAK,CAAc,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,SAAS,EAAE,CAAC;IAC5E,CAAC;IAES,SAAS;QACjB,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,uDAA0B,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC;QAEhI,OAAO,IAAI,CAAC;IACd,CAAC;IAES,UAAU;QAClB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAEtC,MAAM,MAAM,GAAG,IAAA,sBAAa,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE5C,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,GAAY,EAAE,IAAU,EAAE,EAAE;YACvD,MAAM,MAAM,CAAC;gBACX,OAAO,EAAE,GAAG,CAAC,OAAc;gBAC3B,QAAQ,EAAE,GAAG,CAAC,QAAe;gBAC7B,GAAG;aACJ,CAAC,CAAC;YAEH,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;;AA3EH,kCA4EC;AA3EQ,qBAAS,GAAG;IACjB;QACE,OAAO,EAAE,yBAAgB;QACzB,QAAQ,EAAE,8BAAmB;KAC9B;IACD;QACE,OAAO,EAAE,wBAAe;QACxB,QAAQ,EAAE,6BAAkB;KAC7B;IACD;QACE,OAAO,EAAE,wBAAe;QACxB,QAAQ,EAAE,6BAAkB;KAC7B;IACD;QACE,OAAO,EAAE,uBAAc;QACvB,QAAQ,EAAE,4BAAiB;KAC5B;IACD;QACE,OAAO,EAAE,4BAAmB;QAC5B,QAAQ,EAAE,iCAAsB;KACjC;CACF,CAAC","sourcesContent":["import KoaRouter from \"@koa/router\";\nimport {\n createContext,\n PlatformApplication,\n PlatformBuilder,\n PlatformBuilderOptions,\n PlatformExceptions,\n PlatformHandler,\n PlatformRequest,\n PlatformResponse,\n PlatformRouter\n} from \"@tsed/common\";\nimport {Type} from \"@tsed/core\";\nimport Koa, {Context, Next} from \"koa\";\nimport {resourceNotFoundMiddleware} from \"../middlewares/resourceNotFoundMiddleware\";\nimport {PlatformKoaApplication, PlatformKoaHandler, PlatformKoaRequest, PlatformKoaResponse, PlatformKoaRouter} from \"../services\";\n\n/**\n * @platform\n * @koa\n */\nexport class PlatformKoa extends PlatformBuilder<Koa, KoaRouter> {\n static providers = [\n {\n provide: PlatformResponse,\n useClass: PlatformKoaResponse\n },\n {\n provide: PlatformRequest,\n useClass: PlatformKoaRequest\n },\n {\n provide: PlatformHandler,\n useClass: PlatformKoaHandler\n },\n {\n provide: PlatformRouter,\n useClass: PlatformKoaRouter\n },\n {\n provide: PlatformApplication,\n useClass: PlatformKoaApplication\n }\n ];\n\n constructor(options: PlatformBuilderOptions) {\n super(options);\n\n const listener: any = (error: any, ctx: Koa.Context) => {\n this.injector.get<PlatformExceptions>(PlatformExceptions)?.catch(error, ctx.request.$ctx);\n };\n\n this.app.getApp().silent = true;\n this.app.getApp().on(\"error\", listener);\n }\n\n /**\n * Create new serverless application. In this mode, the component scan are disabled.\n * @param module\n * @param settings\n */\n static create(module: Type<any>, settings: Partial<TsED.Configuration> = {}) {\n return this.build<PlatformKoa>(PlatformKoa, module, {\n httpsPort: false,\n httpPort: false,\n ...settings,\n disableComponentsScan: true\n });\n }\n\n static async bootstrap(module: Type<any>, settings: Partial<TsED.Configuration> = {}): Promise<PlatformKoa> {\n return this.build<PlatformKoa>(PlatformKoa, module, settings).bootstrap();\n }\n\n protected useRouter(): this {\n this.app.getApp().use(resourceNotFoundMiddleware).use(this.app.getRouter().routes()).use(this.app.getRouter().allowedMethods());\n\n return this;\n }\n\n protected useContext(): this {\n this.logger.info(\"Mount app context\");\n\n const invoke = createContext(this.injector);\n\n this.app.getApp().use(async (ctx: Context, next: Next) => {\n await invoke({\n request: ctx.request as any,\n response: ctx.response as any,\n ctx\n });\n\n return next();\n });\n\n return this;\n }\n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AAE,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACvF,CAAC,CAAC;QAEF,GAAG,CAAC,MAAM,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC;QAC3B,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACrC,CAAC;IAED,SAAS;QACP,MAAM,EAAC,GAAG,EAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC5B,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,uDAA0B,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC;QAEjH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,UAAU;QACR,MAAM,EAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9C,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAEjC,MAAM,MAAM,GAAG,IAAA,sBAAa,EAAC,QAAQ,CAAC,CAAC;QAEvC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,GAAY,EAAE,IAAU,EAAE,EAAE;YAClD,MAAM,MAAM,CAAC;gBACX,OAAO,EAAE,GAAG,CAAC,OAAc;gBAC3B,QAAQ,EAAE,GAAG,CAAC,QAAe;gBAC7B,GAAG;aACJ,CAAC,CAAC;YAEH,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAtFD,kCAsFC","sourcesContent":["import KoaRouter from \"@koa/router\";\nimport {\n createContext,\n PlatformAdapter,\n PlatformApplication,\n PlatformBuilder,\n PlatformExceptions,\n PlatformHandler,\n PlatformRequest,\n PlatformResponse,\n PlatformRouter\n} from \"@tsed/common\";\nimport {Type} from \"@tsed/core\";\nimport Koa, {Context, Next} from \"koa\";\nimport {resourceNotFoundMiddleware} from \"../middlewares/resourceNotFoundMiddleware\";\nimport {PlatformKoaApplication, PlatformKoaHandler, PlatformKoaRequest, PlatformKoaResponse, PlatformKoaRouter} from \"../services\";\n\n/**\n * @platform\n * @koa\n */\nexport class PlatformKoa implements PlatformAdapter<Koa, KoaRouter> {\n readonly providers = [\n {\n provide: PlatformResponse,\n useClass: PlatformKoaResponse\n },\n {\n provide: PlatformRequest,\n useClass: PlatformKoaRequest\n },\n {\n provide: PlatformHandler,\n useClass: PlatformKoaHandler\n },\n {\n provide: PlatformRouter,\n useClass: PlatformKoaRouter\n },\n {\n provide: PlatformApplication,\n useClass: PlatformKoaApplication\n }\n ];\n\n constructor(private platform: PlatformBuilder<Koa, KoaRouter>) {}\n\n /**\n * Create new serverless application. In this mode, the component scan are disabled.\n * @param module\n * @param settings\n */\n static create(module: Type<any>, settings: Partial<TsED.Configuration> = {}) {\n return PlatformBuilder.create<Koa, KoaRouter>(module, {\n ...settings,\n adapter: PlatformKoa\n });\n }\n\n /**\n * Bootstrap a server application\n * @param module\n * @param settings\n */\n static async bootstrap(module: Type<any>, settings: Partial<TsED.Configuration> = {}) {\n return PlatformBuilder.bootstrap<Koa, KoaRouter>(module, {\n ...settings,\n adapter: PlatformKoa\n });\n }\n\n onInit() {\n const {injector, app} = this.platform;\n\n const listener: any = (error: any, ctx: Koa.Context) => {\n injector.get<PlatformExceptions>(PlatformExceptions)?.catch(error, ctx.request.$ctx);\n };\n\n app.getApp().silent = true;\n app.getApp().on(\"error\", listener);\n }\n\n useRouter(): this {\n const {app} = this.platform;\n app.getApp().use(resourceNotFoundMiddleware).use(app.getRouter().routes()).use(app.getRouter().allowedMethods());\n\n return this;\n }\n\n useContext(): this {\n const {injector, app, logger} = this.platform;\n logger.info(\"Mount app context\");\n\n const invoke = createContext(injector);\n\n app.getApp().use(async (ctx: Context, next: Next) => {\n await invoke({\n request: ctx.request as any,\n response: ctx.response as any,\n ctx\n });\n\n return next();\n });\n\n return this;\n }\n}\n"]}
package/lib/cjs/index.js CHANGED
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const common_1 = require("@tsed/common");
5
5
  const PlatformKoa_1 = require("./components/PlatformKoa");
6
- common_1.PlatformTest.platformBuilder = PlatformKoa_1.PlatformKoa;
7
- common_1.PlatformBuilder.currentPlatform = PlatformKoa_1.PlatformKoa;
6
+ common_1.PlatformTest.adapter = PlatformKoa_1.PlatformKoa;
7
+ common_1.PlatformBuilder.adapter = PlatformKoa_1.PlatformKoa;
8
8
  // interfaces
9
9
  (0, tslib_1.__exportStar)(require("./interfaces"), exports);
10
10
  // decorators
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAA2D;AAC3D,0DAAqD;AAErD,qBAAY,CAAC,eAAe,GAAG,yBAAW,CAAC;AAC3C,wBAAe,CAAC,eAAe,GAAG,yBAAkB,CAAC;AAErD,aAAa;AACb,4DAA6B;AAE7B,aAAa;AACb,4DAA6B;AAE7B,WAAW;AACX,0DAA2B;AAE3B,aAAa;AACb,wEAAyC","sourcesContent":["import {PlatformBuilder, PlatformTest} from \"@tsed/common\";\nimport {PlatformKoa} from \"./components/PlatformKoa\";\n\nPlatformTest.platformBuilder = PlatformKoa;\nPlatformBuilder.currentPlatform = PlatformKoa as any;\n\n// interfaces\nexport * from \"./interfaces\";\n\n// decorators\nexport * from \"./decorators\";\n\n// services\nexport * from \"./services\";\n\n// components\nexport * from \"./components/PlatformKoa\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAA2D;AAC3D,0DAAqD;AAErD,qBAAY,CAAC,OAAO,GAAG,yBAAW,CAAC;AACnC,wBAAe,CAAC,OAAO,GAAG,yBAAW,CAAC;AAEtC,aAAa;AACb,4DAA6B;AAE7B,aAAa;AACb,4DAA6B;AAE7B,WAAW;AACX,0DAA2B;AAE3B,aAAa;AACb,wEAAyC","sourcesContent":["import {PlatformBuilder, PlatformTest} from \"@tsed/common\";\nimport {PlatformKoa} from \"./components/PlatformKoa\";\n\nPlatformTest.adapter = PlatformKoa;\nPlatformBuilder.adapter = PlatformKoa;\n\n// interfaces\nexport * from \"./interfaces\";\n\n// decorators\nexport * from \"./decorators\";\n\n// services\nexport * from \"./services\";\n\n// components\nexport * from \"./components/PlatformKoa\";\n"]}
@@ -5,15 +5,31 @@ import { PlatformKoaApplication, PlatformKoaHandler, PlatformKoaRequest, Platfor
5
5
  * @platform
6
6
  * @koa
7
7
  */
8
- export class PlatformKoa extends PlatformBuilder {
9
- constructor(options) {
10
- super(options);
11
- const listener = (error, ctx) => {
12
- var _a;
13
- (_a = this.injector.get(PlatformExceptions)) === null || _a === void 0 ? void 0 : _a.catch(error, ctx.request.$ctx);
14
- };
15
- this.app.getApp().silent = true;
16
- this.app.getApp().on("error", listener);
8
+ export class PlatformKoa {
9
+ constructor(platform) {
10
+ this.platform = platform;
11
+ this.providers = [
12
+ {
13
+ provide: PlatformResponse,
14
+ useClass: PlatformKoaResponse
15
+ },
16
+ {
17
+ provide: PlatformRequest,
18
+ useClass: PlatformKoaRequest
19
+ },
20
+ {
21
+ provide: PlatformHandler,
22
+ useClass: PlatformKoaHandler
23
+ },
24
+ {
25
+ provide: PlatformRouter,
26
+ useClass: PlatformKoaRouter
27
+ },
28
+ {
29
+ provide: PlatformApplication,
30
+ useClass: PlatformKoaApplication
31
+ }
32
+ ];
17
33
  }
18
34
  /**
19
35
  * Create new serverless application. In this mode, the component scan are disabled.
@@ -21,24 +37,41 @@ export class PlatformKoa extends PlatformBuilder {
21
37
  * @param settings
22
38
  */
23
39
  static create(module, settings = {}) {
24
- return this.build(PlatformKoa, module, {
25
- httpsPort: false,
26
- httpPort: false,
40
+ return PlatformBuilder.create(module, {
27
41
  ...settings,
28
- disableComponentsScan: true
42
+ adapter: PlatformKoa
29
43
  });
30
44
  }
45
+ /**
46
+ * Bootstrap a server application
47
+ * @param module
48
+ * @param settings
49
+ */
31
50
  static async bootstrap(module, settings = {}) {
32
- return this.build(PlatformKoa, module, settings).bootstrap();
51
+ return PlatformBuilder.bootstrap(module, {
52
+ ...settings,
53
+ adapter: PlatformKoa
54
+ });
55
+ }
56
+ onInit() {
57
+ const { injector, app } = this.platform;
58
+ const listener = (error, ctx) => {
59
+ var _a;
60
+ (_a = injector.get(PlatformExceptions)) === null || _a === void 0 ? void 0 : _a.catch(error, ctx.request.$ctx);
61
+ };
62
+ app.getApp().silent = true;
63
+ app.getApp().on("error", listener);
33
64
  }
34
65
  useRouter() {
35
- this.app.getApp().use(resourceNotFoundMiddleware).use(this.app.getRouter().routes()).use(this.app.getRouter().allowedMethods());
66
+ const { app } = this.platform;
67
+ app.getApp().use(resourceNotFoundMiddleware).use(app.getRouter().routes()).use(app.getRouter().allowedMethods());
36
68
  return this;
37
69
  }
38
70
  useContext() {
39
- this.logger.info("Mount app context");
40
- const invoke = createContext(this.injector);
41
- this.app.getApp().use(async (ctx, next) => {
71
+ const { injector, app, logger } = this.platform;
72
+ logger.info("Mount app context");
73
+ const invoke = createContext(injector);
74
+ app.getApp().use(async (ctx, next) => {
42
75
  await invoke({
43
76
  request: ctx.request,
44
77
  response: ctx.response,
@@ -49,26 +82,4 @@ export class PlatformKoa extends PlatformBuilder {
49
82
  return this;
50
83
  }
51
84
  }
52
- PlatformKoa.providers = [
53
- {
54
- provide: PlatformResponse,
55
- useClass: PlatformKoaResponse
56
- },
57
- {
58
- provide: PlatformRequest,
59
- useClass: PlatformKoaRequest
60
- },
61
- {
62
- provide: PlatformHandler,
63
- useClass: PlatformKoaHandler
64
- },
65
- {
66
- provide: PlatformRouter,
67
- useClass: PlatformKoaRouter
68
- },
69
- {
70
- provide: PlatformApplication,
71
- useClass: PlatformKoaApplication
72
- }
73
- ];
74
85
  //# sourceMapp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aRouter from \"@koa/router\";\nimport {\n createContext,\n PlatformApplication,\n PlatformBuilder,\n PlatformBuilderOptions,\n PlatformExceptions,\n PlatformHandler,\n PlatformRequest,\n PlatformResponse,\n PlatformRouter\n} from \"@tsed/common\";\nimport {Type} from \"@tsed/core\";\nimport Koa, {Context, Next} from \"koa\";\nimport {resourceNotFoundMiddleware} from \"../middlewares/resourceNotFoundMiddleware\";\nimport {PlatformKoaApplication, PlatformKoaHandler, PlatformKoaRequest, PlatformKoaResponse, PlatformKoaRouter} from \"../services\";\n\n/**\n * @platform\n * @koa\n */\nexport class PlatformKoa extends PlatformBuilder<Koa, KoaRouter> {\n static providers = [\n {\n provide: PlatformResponse,\n useClass: PlatformKoaResponse\n },\n {\n provide: PlatformRequest,\n useClass: PlatformKoaRequest\n },\n {\n provide: PlatformHandler,\n useClass: PlatformKoaHandler\n },\n {\n provide: PlatformRouter,\n useClass: PlatformKoaRouter\n },\n {\n provide: PlatformApplication,\n useClass: PlatformKoaApplication\n }\n ];\n\n constructor(options: PlatformBuilderOptions) {\n super(options);\n\n const listener: any = (error: any, ctx: Koa.Context) => {\n this.injector.get<PlatformExceptions>(PlatformExceptions)?.catch(error, ctx.request.$ctx);\n };\n\n this.app.getApp().silent = true;\n this.app.getApp().on(\"error\", listener);\n }\n\n /**\n * Create new serverless application. In this mode, the component scan are disabled.\n * @param module\n * @param settings\n */\n static create(module: Type<any>, settings: Partial<TsED.Configuration> = {}) {\n return this.build<PlatformKoa>(PlatformKoa, module, {\n httpsPort: false,\n httpPort: false,\n ...settings,\n disableComponentsScan: true\n });\n }\n\n static async bootstrap(module: Type<any>, settings: Partial<TsED.Configuration> = {}): Promise<PlatformKoa> {\n return this.build<PlatformKoa>(PlatformKoa, module, settings).bootstrap();\n }\n\n protected useRouter(): this {\n this.app.getApp().use(resourceNotFoundMiddleware).use(this.app.getRouter().routes()).use(this.app.getRouter().allowedMethods());\n\n return this;\n }\n\n protected useContext(): this {\n this.logger.info(\"Mount app context\");\n\n const invoke = createContext(this.injector);\n\n this.app.getApp().use(async (ctx: Context, next: Next) => {\n await invoke({\n request: ctx.request as any,\n response: ctx.response as any,\n ctx\n });\n\n return next();\n });\n\n return this;\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformKoa.js","sourceRoot":"","sources":["../../../src/components/PlatformKoa.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAEb,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,cAAc,EACf,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAC,0BAA0B,EAAC,MAAM,2CAA2C,CAAC;AACrF,OAAO,EAAC,sBAAsB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,iBAAiB,EAAC,MAAM,aAAa,CAAC;AAEnI;;;GAGG;AACH,MAAM,OAAO,WAAW;IAwBtB,YAAoB,QAAyC;QAAzC,aAAQ,GAAR,QAAQ,CAAiC;QAvBpD,cAAS,GAAG;YACnB;gBACE,OAAO,EAAE,gBAAgB;gBACzB,QAAQ,EAAE,mBAAmB;aAC9B;YACD;gBACE,OAAO,EAAE,eAAe;gBACxB,QAAQ,EAAE,kBAAkB;aAC7B;YACD;gBACE,OAAO,EAAE,eAAe;gBACxB,QAAQ,EAAE,kBAAkB;aAC7B;YACD;gBACE,OAAO,EAAE,cAAc;gBACvB,QAAQ,EAAE,iBAAiB;aAC5B;YACD;gBACE,OAAO,EAAE,mBAAmB;gBAC5B,QAAQ,EAAE,sBAAsB;aACjC;SACF,CAAC;IAE8D,CAAC;IAEjE;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,MAAiB,EAAE,WAAwC,EAAE;QACzE,OAAO,eAAe,CAAC,MAAM,CAAiB,MAAM,EAAE;YACpD,GAAG,QAAQ;YACX,OAAO,EAAE,WAAW;SACrB,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,MA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O,EAAE,GAAG,CAAC,OAAc;gBAC3B,QAAQ,EAAE,GAAG,CAAC,QAAe;gBAC7B,GAAG;aACJ,CAAC,CAAC;YAEH,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import KoaRouter from \"@koa/router\";\nimport {\n createContext,\n PlatformAdapter,\n PlatformApplication,\n PlatformBuilder,\n PlatformExceptions,\n PlatformHandler,\n PlatformRequest,\n PlatformResponse,\n PlatformRouter\n} from \"@tsed/common\";\nimport {Type} from \"@tsed/core\";\nimport Koa, {Context, Next} from \"koa\";\nimport {resourceNotFoundMiddleware} from \"../middlewares/resourceNotFoundMiddleware\";\nimport {PlatformKoaApplication, PlatformKoaHandler, PlatformKoaRequest, PlatformKoaResponse, PlatformKoaRouter} from \"../services\";\n\n/**\n * @platform\n * @koa\n */\nexport class PlatformKoa implements PlatformAdapter<Koa, KoaRouter> {\n readonly providers = [\n {\n provide: PlatformResponse,\n useClass: PlatformKoaResponse\n },\n {\n provide: PlatformRequest,\n useClass: PlatformKoaRequest\n },\n {\n provide: PlatformHandler,\n useClass: PlatformKoaHandler\n },\n {\n provide: PlatformRouter,\n useClass: PlatformKoaRouter\n },\n {\n provide: PlatformApplication,\n useClass: PlatformKoaApplication\n }\n ];\n\n constructor(private platform: PlatformBuilder<Koa, KoaRouter>) {}\n\n /**\n * Create new serverless application. In this mode, the component scan are disabled.\n * @param module\n * @param settings\n */\n static create(module: Type<any>, settings: Partial<TsED.Configuration> = {}) {\n return PlatformBuilder.create<Koa, KoaRouter>(module, {\n ...settings,\n adapter: PlatformKoa\n });\n }\n\n /**\n * Bootstrap a server application\n * @param module\n * @param settings\n */\n static async bootstrap(module: Type<any>, settings: Partial<TsED.Configuration> = {}) {\n return PlatformBuilder.bootstrap<Koa, KoaRouter>(module, {\n ...settings,\n adapter: PlatformKoa\n });\n }\n\n onInit() {\n const {injector, app} = this.platform;\n\n const listener: any = (error: any, ctx: Koa.Context) => {\n injector.get<PlatformExceptions>(PlatformExceptions)?.catch(error, ctx.request.$ctx);\n };\n\n app.getApp().silent = true;\n app.getApp().on(\"error\", listener);\n }\n\n useRouter(): this {\n const {app} = this.platform;\n app.getApp().use(resourceNotFoundMiddleware).use(app.getRouter().routes()).use(app.getRouter().allowedMethods());\n\n return this;\n }\n\n useContext(): this {\n const {injector, app, logger} = this.platform;\n logger.info(\"Mount app context\");\n\n const invoke = createContext(injector);\n\n app.getApp().use(async (ctx: Context, next: Next) => {\n await invoke({\n request: ctx.request as any,\n response: ctx.response as any,\n ctx\n });\n\n return next();\n });\n\n return this;\n }\n}\n"]}
package/lib/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PlatformBuilder, PlatformTest } from "@tsed/common";
2
2
  import { PlatformKoa } from "./components/PlatformKoa";
3
- PlatformTest.platformBuilder = PlatformKoa;
4
- PlatformBuilder.currentPlatform = PlatformKoa;
3
+ PlatformTest.adapter = PlatformKoa;
4
+ PlatformBuilder.adapter = PlatformKoa;
5
5
  // interfaces
6
6
  export * from "./interfaces";
7
7
  // decorators
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;AAErD,YAAY,CAAC,eAAe,GAAG,WAAW,CAAC;AAC3C,eAAe,CAAC,eAAe,GAAG,WAAkB,CAAC;AAErD,aAAa;AACb,cAAc,cAAc,CAAC;AAE7B,aAAa;AACb,cAAc,cAAc,CAAC;AAE7B,WAAW;AACX,cAAc,YAAY,CAAC;AAE3B,aAAa;AACb,cAAc,0BAA0B,CAAC","sourcesContent":["import {PlatformBuilder, PlatformTest} from \"@tsed/common\";\nimport {PlatformKoa} from \"./components/PlatformKoa\";\n\nPlatformTest.platformBuilder = PlatformKoa;\nPlatformBuilder.currentPlatform = PlatformKoa as any;\n\n// interfaces\nexport * from \"./interfaces\";\n\n// decorators\nexport * from \"./decorators\";\n\n// services\nexport * from \"./services\";\n\n// components\nexport * from \"./components/PlatformKoa\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;AAErD,YAAY,CAAC,OAAO,GAAG,WAAW,CAAC;AACnC,eAAe,CAAC,OAAO,GAAG,WAAW,CAAC;AAEtC,aAAa;AACb,cAAc,cAAc,CAAC;AAE7B,aAAa;AACb,cAAc,cAAc,CAAC;AAE7B,WAAW;AACX,cAAc,YAAY,CAAC;AAE3B,aAAa;AACb,cAAc,0BAA0B,CAAC","sourcesContent":["import {PlatformBuilder, PlatformTest} from \"@tsed/common\";\nimport {PlatformKoa} from \"./components/PlatformKoa\";\n\nPlatformTest.adapter = PlatformKoa;\nPlatformBuilder.adapter = PlatformKoa;\n\n// interfaces\nexport * from \"./interfaces\";\n\n// decorators\nexport * from \"./decorators\";\n\n// services\nexport * from \"./services\";\n\n// components\nexport * from \"./components/PlatformKoa\";\n"]}
@@ -1,6 +1,6 @@
1
1
  /// <reference types="koa__router" />
2
2
  import KoaRouter from "@koa/router";
3
- import { PlatformApplication, PlatformBuilder, PlatformBuilderOptions, PlatformHandler, PlatformRequest, PlatformResponse, PlatformRouter } from "@tsed/common";
3
+ import { PlatformAdapter, PlatformApplication, PlatformBuilder, PlatformHandler, PlatformRequest, PlatformResponse, PlatformRouter } from "@tsed/common";
4
4
  import { Type } from "@tsed/core";
5
5
  import Koa from "koa";
6
6
  import { PlatformKoaApplication, PlatformKoaHandler, PlatformKoaRequest, PlatformKoaResponse, PlatformKoaRouter } from "../services";
@@ -8,8 +8,9 @@ import { PlatformKoaApplication, PlatformKoaHandler, PlatformKoaRequest, Platfor
8
8
  * @platform
9
9
  * @koa
10
10
  */
11
- export declare class PlatformKoa extends PlatformBuilder<Koa, KoaRouter> {
12
- static providers: ({
11
+ export declare class PlatformKoa implements PlatformAdapter<Koa, KoaRouter> {
12
+ private platform;
13
+ readonly providers: ({
13
14
  provide: typeof PlatformResponse;
14
15
  useClass: typeof PlatformKoaResponse;
15
16
  } | {
@@ -25,14 +26,20 @@ export declare class PlatformKoa extends PlatformBuilder<Koa, KoaRouter> {
25
26
  provide: typeof PlatformApplication;
26
27
  useClass: typeof PlatformKoaApplication;
27
28
  })[];
28
- constructor(options: PlatformBuilderOptions);
29
+ constructor(platform: PlatformBuilder<Koa, KoaRouter>);
29
30
  /**
30
31
  * Create new serverless application. In this mode, the component scan are disabled.
31
32
  * @param module
32
33
  * @param settings
33
34
  */
34
- static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformKoa;
35
- static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformKoa>;
36
- protected useRouter(): this;
37
- protected useContext(): this;
35
+ static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<Koa<Koa.DefaultState, Koa.DefaultContext>, KoaRouter<any, {}>>;
36
+ /**
37
+ * Bootstrap a server application
38
+ * @param module
39
+ * @param settings
40
+ */
41
+ static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<Koa<Koa.DefaultState, Koa.DefaultContext>, KoaRouter<any, {}>>>;
42
+ onInit(): void;
43
+ useRouter(): this;
44
+ useContext(): this;
38
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/platform-koa",
3
- "version": "6.89.0",
3
+ "version": "6.90.0",
4
4
  "description": "Koa package for Ts.ED framework",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
@@ -49,10 +49,10 @@
49
49
  "repository": "https://github.com/tsedio/tsed",
50
50
  "devDependencies": {
51
51
  "@koa/cors": "3.1.0",
52
- "@tsed/common": "6.89.0",
53
- "@tsed/core": "6.89.0",
54
- "@tsed/di": "6.89.0",
55
- "@tsed/platform-test-utils": "6.89.0",
52
+ "@tsed/common": "6.90.0",
53
+ "@tsed/core": "6.90.0",
54
+ "@tsed/di": "6.90.0",
55
+ "@tsed/platform-test-utils": "6.90.0",
56
56
  "@types/koa": "2.11.3",
57
57
  "@types/koa-bodyparser": "4.3.0",
58
58
  "@types/koa-compose": "3.2.5",
@@ -77,13 +77,13 @@
77
77
  "tslib": "2.2.0"
78
78
  },
79
79
  "peerDependencies": {
80
- "@tsed/common": "^6.89.0",
81
- "@tsed/core": "^6.89.0",
82
- "@tsed/di": "^6.89.0",
83
- "@tsed/json-mapper": "^6.89.0",
80
+ "@tsed/common": "^6.90.0",
81
+ "@tsed/core": "^6.90.0",
82
+ "@tsed/di": "^6.90.0",
83
+ "@tsed/json-mapper": "^6.90.0",
84
84
  "@tsed/logger": ">=6.0.0",
85
- "@tsed/openspec": "^6.89.0",
86
- "@tsed/schema": "^6.89.0",
85
+ "@tsed/openspec": "^6.90.0",
86
+ "@tsed/schema": "^6.90.0",
87
87
  "koa": ">=2.13.0",
88
88
  "koa-bodyparser": ">=4.3.0",
89
89
  "koa-compress": ">=5.0.1",