@tsed/platform-koa 6.83.0 → 6.86.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, PlatformHandler, PlatformRequest, PlatformResponse, PlatformRouter } from "@tsed/common";
3
+ import { PlatformApplication, PlatformBuilder, PlatformBuilderOptions, 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";
@@ -25,8 +25,14 @@ export declare class PlatformKoa extends PlatformBuilder<Koa, KoaRouter> {
25
25
  provide: typeof PlatformApplication;
26
26
  useClass: typeof PlatformKoaApplication;
27
27
  })[];
28
+ constructor(options: PlatformBuilderOptions);
29
+ /**
30
+ * Create new serverless application. In this mode, the component scan are disabled.
31
+ * @param module
32
+ * @param settings
33
+ */
34
+ static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformKoa;
28
35
  static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformKoa>;
29
- protected createInjector(module: Type<any>, settings: any): void;
30
36
  protected useRouter(): this;
31
37
  protected useContext(): this;
32
38
  }
@@ -9,11 +9,8 @@ const services_1 = require("../services");
9
9
  * @koa
10
10
  */
11
11
  class PlatformKoa extends common_1.PlatformBuilder {
12
- static async bootstrap(module, settings = {}) {
13
- return this.build(PlatformKoa).bootstrap(module, settings);
14
- }
15
- createInjector(module, settings) {
16
- super.createInjector(module, settings);
12
+ constructor(options) {
13
+ super(options);
17
14
  const listener = (error, ctx) => {
18
15
  var _a;
19
16
  (_a = this.injector.get(common_1.PlatformExceptions)) === null || _a === void 0 ? void 0 : _a.catch(error, ctx.request.$ctx);
@@ -21,6 +18,22 @@ class PlatformKoa extends common_1.PlatformBuilder {
21
18
  this.app.getApp().silent = true;
22
19
  this.app.getApp().on("error", listener);
23
20
  }
21
+ /**
22
+ * Create new serverless application. In this mode, the component scan are disabled.
23
+ * @param module
24
+ * @param settings
25
+ */
26
+ static create(module, settings = {}) {
27
+ return this.build(PlatformKoa, module, {
28
+ httpsPort: false,
29
+ httpPort: false,
30
+ ...settings,
31
+ disableComponentsScan: true
32
+ });
33
+ }
34
+ static async bootstrap(module, settings = {}) {
35
+ return this.build(PlatformKoa, module, settings).bootstrap();
36
+ }
24
37
  useRouter() {
25
38
  this.app.getApp().use(resourceNotFoundMiddleware_1.resourceNotFoundMiddleware).use(this.app.getRouter().routes()).use(this.app.getRouter().allowedMethods());
26
39
  return this;
@@ -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,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,MAAiB,EAAE,WAAwC,EAAE;QAClF,OAAO,IAAI,CAAC,KAAK,CAAc,WAAW,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC1E,CAAC;IAES,cAAc,CAAC,MAAiB,EAAE,QAAa;QACvD,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAEvC,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,C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","sourcesContent":["import KoaRouter from \"@koa/router\";\nimport {\n createContext,\n PlatformApplication,\n PlatformBuilder,\n PlatformExceptions,\n PlatformHandler,\n PlatformRequest,\n PlatformResponse,\n PlatformRouter,\n PlatformViews\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 static async bootstrap(module: Type<any>, settings: Partial<TsED.Configuration> = {}): Promise<PlatformKoa> {\n return this.build<PlatformKoa>(PlatformKoa).bootstrap(module, settings);\n }\n\n protected createInjector(module: Type<any>, settings: any) {\n super.createInjector(module, settings);\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 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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,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,sBAAa,CAAC,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 IProvider,\n PlatformApplication,\n PlatformBuilder,\n PlatformBuilderOptions,\n PlatformExceptions,\n PlatformHandler,\n PlatformRequest,\n PlatformResponse,\n PlatformRouter,\n PlatformViews\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\";\nimport {getConfiguration} from \"@tsed/common/src/utils/getConfiguration\";\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/platform-koa",
3
- "version": "6.83.0",
3
+ "version": "6.86.0",
4
4
  "description": "Koa package for Ts.ED framework",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/index.js",
@@ -41,10 +41,10 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@koa/cors": "3.1.0",
44
- "@tsed/common": "6.83.0",
45
- "@tsed/core": "6.83.0",
46
- "@tsed/di": "6.83.0",
47
- "@tsed/platform-test-utils": "6.83.0",
44
+ "@tsed/common": "6.86.0",
45
+ "@tsed/core": "6.86.0",
46
+ "@tsed/di": "6.86.0",
47
+ "@tsed/platform-test-utils": "6.86.0",
48
48
  "@types/koa": "2.11.3",
49
49
  "@types/koa-bodyparser": "4.3.0",
50
50
  "@types/koa-compose": "3.2.5",
@@ -69,13 +69,13 @@
69
69
  "tslib": "2.2.0"
70
70
  },
71
71
  "peerDependencies": {
72
- "@tsed/common": "^6.83.0",
73
- "@tsed/core": "^6.83.0",
74
- "@tsed/di": "^6.83.0",
75
- "@tsed/json-mapper": "^6.83.0",
72
+ "@tsed/common": "^6.86.0",
73
+ "@tsed/core": "^6.86.0",
74
+ "@tsed/di": "^6.86.0",
75
+ "@tsed/json-mapper": "^6.86.0",
76
76
  "@tsed/logger": ">=6.0.0",
77
- "@tsed/openspec": "^6.83.0",
78
- "@tsed/schema": "^6.83.0",
77
+ "@tsed/openspec": "^6.86.0",
78
+ "@tsed/schema": "^6.86.0",
79
79
  "koa": ">=2.13.0",
80
80
  "koa-bodyparser": ">=4.3.0",
81
81
  "koa-compress": ">=5.0.1",