@tsed/platform-koa 8.0.0-rc.5 → 8.0.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,10 +1,8 @@
1
- var PlatformKoa_1;
2
- import { __decorate } from "tslib";
3
1
  import KoaRouter from "@koa/router";
4
2
  import { catchAsyncError, isFunction } from "@tsed/core";
5
- import { runInContext } from "@tsed/di";
3
+ import { constant, inject, runInContext } from "@tsed/di";
6
4
  import { PlatformExceptions } from "@tsed/platform-exceptions";
7
- import { createContext, PlatformAdapter, PlatformBuilder, PlatformHandler, PlatformProvider, PlatformRequest, PlatformResponse } from "@tsed/platform-http";
5
+ import { adapter, application, createContext, Platform, PlatformAdapter, PlatformApplication, PlatformBuilder, PlatformHandler, PlatformRequest, PlatformResponse } from "@tsed/platform-http";
8
6
  import { PlatformHandlerType } from "@tsed/platform-router";
9
7
  import Koa from "koa";
10
8
  import koaBodyParser from "koa-bodyparser";
@@ -30,26 +28,27 @@ KoaRouter.prototype.match = function match(...args) {
30
28
  * @platform
31
29
  * @koa
32
30
  */
33
- let PlatformKoa = class PlatformKoa extends PlatformAdapter {
31
+ export class PlatformKoa extends PlatformAdapter {
34
32
  constructor() {
35
33
  super(...arguments);
34
+ this.NAME = "koa";
36
35
  this.providers = [
37
36
  {
38
- provide: PlatformResponse,
37
+ token: PlatformResponse,
39
38
  useClass: PlatformKoaResponse
40
39
  },
41
40
  {
42
- provide: PlatformRequest,
41
+ token: PlatformRequest,
43
42
  useClass: PlatformKoaRequest
44
43
  },
45
44
  {
46
- provide: PlatformHandler,
45
+ token: PlatformHandler,
47
46
  useClass: PlatformKoaHandler
48
- }
47
+ },
48
+ { token: PlatformApplication },
49
+ { token: Platform }
49
50
  ];
50
51
  }
51
- static { PlatformKoa_1 = this; }
52
- static { this.NAME = "koa"; }
53
52
  /**
54
53
  * Create new serverless application. In this mode, the component scan are disabled.
55
54
  * @param module
@@ -58,7 +57,7 @@ let PlatformKoa = class PlatformKoa extends PlatformAdapter {
58
57
  static create(module, settings = {}) {
59
58
  return PlatformBuilder.create(module, {
60
59
  ...settings,
61
- adapter: PlatformKoa_1
60
+ adapter: PlatformKoa
62
61
  });
63
62
  }
64
63
  /**
@@ -69,16 +68,14 @@ let PlatformKoa = class PlatformKoa extends PlatformAdapter {
69
68
  static bootstrap(module, settings = {}) {
70
69
  return PlatformBuilder.bootstrap(module, {
71
70
  ...settings,
72
- adapter: PlatformKoa_1
71
+ adapter: PlatformKoa
73
72
  });
74
73
  }
75
74
  onInit() {
76
75
  this.app.getApp().silent = true;
77
76
  }
78
77
  mapLayers(layers) {
79
- const { settings } = this.injector;
80
- const { app } = this;
81
- const options = settings.get("koa.router", {});
78
+ const options = constant("koa.router", {});
82
79
  const rawRouter = new KoaRouter(options);
83
80
  layers.forEach((layer) => {
84
81
  switch (layer.method) {
@@ -89,7 +86,7 @@ let PlatformKoa = class PlatformKoa extends PlatformAdapter {
89
86
  rawRouter[layer.method](...layer.getArgs());
90
87
  }
91
88
  });
92
- app.getApp().use(rawRouter.routes()).use(rawRouter.allowedMethods());
89
+ application().getApp().use(rawRouter.routes()).use(rawRouter.allowedMethods());
93
90
  }
94
91
  mapHandler(handler, metadata) {
95
92
  return async (koaContext, next) => {
@@ -105,10 +102,9 @@ let PlatformKoa = class PlatformKoa extends PlatformAdapter {
105
102
  };
106
103
  }
107
104
  useContext() {
108
- const { app } = this;
109
- const invoke = createContext(this.injector);
110
- const platformExceptions = this.injector.get(PlatformExceptions);
111
- app.use((koaContext, next) => {
105
+ const invoke = createContext();
106
+ const platformExceptions = inject(PlatformExceptions);
107
+ application().use((koaContext, next) => {
112
108
  const $ctx = invoke({
113
109
  request: koaContext.request,
114
110
  response: koaContext.response,
@@ -134,7 +130,7 @@ let PlatformKoa = class PlatformKoa extends PlatformAdapter {
134
130
  return this;
135
131
  }
136
132
  createApp() {
137
- const app = this.injector.settings.get("koa.app") || new Koa();
133
+ const app = constant("koa.app") || new Koa();
138
134
  koaQs(app, "extended");
139
135
  return {
140
136
  app,
@@ -149,8 +145,8 @@ let PlatformKoa = class PlatformKoa extends PlatformAdapter {
149
145
  statics(endpoint, options) {
150
146
  return staticsMiddleware(options);
151
147
  }
152
- bodyParser(type, additionalOptions = {}) {
153
- const opts = this.injector.settings.get(`koa.bodyParser`);
148
+ bodyParser(_, additionalOptions = {}) {
149
+ const opts = constant(`koa.bodyParser`);
154
150
  let parser = koaBodyParser;
155
151
  let options = {};
156
152
  if (isFunction(opts)) {
@@ -159,9 +155,6 @@ let PlatformKoa = class PlatformKoa extends PlatformAdapter {
159
155
  }
160
156
  return parser({ ...options, ...additionalOptions });
161
157
  }
162
- };
163
- PlatformKoa = PlatformKoa_1 = __decorate([
164
- PlatformProvider()
165
- ], PlatformKoa);
166
- export { PlatformKoa };
158
+ }
159
+ adapter(PlatformKoa);
167
160
  //# sourceMappingURL=PlatformKoa.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformKoa.js","sourceRoot":"","sources":["../../../src/components/PlatformKoa.ts"],"names":[],"mappings":";;AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,EAAC,eAAe,EAAE,UAAU,EAAO,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;AACtC,OAAO,EAAC,kBAAkB,EAAC,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,EACf,eAAe,EAGf,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAEjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAA0B,mBAAmB,EAAgB,MAAM,uBAAuB,CAAC;AAClG,OAAO,GAAoB,MAAM,KAAK,CAAC;AACvC,OAAO,aAAwB,MAAM,gBAAgB,CAAC;AACtD,aAAa;AACb,OAAO,KAAK,MAAM,QAAQ,CAAC;AAG3B,OAAO,EAAC,iBAAiB,EAAC,MAAM,qCAAqC,CAAC;AACtE,OAAO,EA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AAO,CAAC,CAAC;IACpC,CAAC;IAED,UAAU,CAAC,CAAyC,EAAE,oBAAyB,EAAE;QAC/E,MAAM,IAAI,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QACxC,IAAI,MAAM,GAAQ,aAAa,CAAC;QAEhC,IAAI,OAAO,GAAY,EAAE,CAAC;QAE1B,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACrB,MAAM,GAAG,IAAI,CAAC;YACd,OAAO,GAAG,EAAE,CAAC;QACf,CAAC;QAED,OAAO,MAAM,CAAC,EAAC,GAAG,OAAO,EAAE,GAAG,iBAAiB,EAAC,CAAC,CAAC;IACpD,CAAC;CACF;AAED,OAAO,CAAC,WAAW,CAAC,CAAC"}
@@ -1,5 +1,7 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
1
3
  import { Type } from "@tsed/core";
2
- import { PlatformAdapter, PlatformBuilder, PlatformHandler, PlatformMulter, PlatformMulterSettings, PlatformRequest, PlatformResponse, PlatformStaticsOptions } from "@tsed/platform-http";
4
+ import { Platform, PlatformAdapter, PlatformApplication, PlatformBuilder, PlatformHandler, PlatformMulter, PlatformMulterSettings, PlatformRequest, PlatformResponse, PlatformStaticsOptions } from "@tsed/platform-http";
3
5
  import { PlatformHandlerMetadata, PlatformLayer } from "@tsed/platform-router";
4
6
  import Koa, { Context, Next } from "koa";
5
7
  import send from "koa-send";
@@ -21,38 +23,44 @@ declare global {
21
23
  * @koa
22
24
  */
23
25
  export declare class PlatformKoa extends PlatformAdapter<Koa> {
24
- static readonly NAME = "koa";
26
+ readonly NAME = "koa";
25
27
  readonly providers: ({
26
- provide: typeof PlatformResponse;
28
+ token: typeof PlatformResponse;
27
29
  useClass: typeof PlatformKoaResponse;
28
30
  } | {
29
- provide: typeof PlatformRequest;
31
+ token: typeof PlatformRequest;
30
32
  useClass: typeof PlatformKoaRequest;
31
33
  } | {
32
- provide: typeof PlatformHandler;
34
+ token: typeof PlatformHandler;
33
35
  useClass: typeof PlatformKoaHandler;
36
+ } | {
37
+ token: typeof PlatformApplication;
38
+ useClass?: undefined;
39
+ } | {
40
+ token: typeof Platform;
41
+ useClass?: undefined;
34
42
  })[];
35
43
  /**
36
44
  * Create new serverless application. In this mode, the component scan are disabled.
37
45
  * @param module
38
46
  * @param settings
39
47
  */
40
- static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<Koa<Koa.DefaultState, Koa.DefaultContext>>;
48
+ static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<TsED.Application>;
41
49
  /**
42
50
  * Bootstrap a server application
43
51
  * @param module
44
52
  * @param settings
45
53
  */
46
- static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<Koa<Koa.DefaultState, Koa.DefaultContext>>>;
54
+ static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<TsED.Application>>;
47
55
  onInit(): void;
48
56
  mapLayers(layers: PlatformLayer[]): void;
49
57
  mapHandler(handler: Function, metadata: PlatformHandlerMetadata): (koaContext: Koa.Context, next: Koa.Next) => Promise<any>;
50
58
  useContext(): this;
51
59
  createApp(): {
52
- app: any;
53
- callback(): any;
60
+ app: Koa<Koa.DefaultState, Koa.DefaultContext>;
61
+ callback(): (req: import("http").IncomingMessage | import("http2").Http2ServerRequest, res: import("http").ServerResponse<import("http").IncomingMessage> | import("http2").Http2ServerResponse<import("http2").Http2ServerRequest>) => Promise<void>;
54
62
  };
55
63
  multipart(options: PlatformMulterSettings): PlatformMulter;
56
64
  statics(endpoint: string, options: PlatformStaticsOptions): any;
57
- bodyParser(type: "json" | "urlencoded" | "raw" | "text", additionalOptions?: any): any;
65
+ bodyParser(_: "json" | "urlencoded" | "raw" | "text", additionalOptions?: any): any;
58
66
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tsed/platform-koa",
3
3
  "description": "Koa package for Ts.ED framework",
4
4
  "type": "module",
5
- "version": "8.0.0-rc.5",
5
+ "version": "8.0.0",
6
6
  "source": "./src/index.ts",
7
7
  "main": "./lib/esm/index.js",
8
8
  "module": "./lib/esm/index.js",
@@ -53,12 +53,12 @@
53
53
  "repository": "https://github.com/tsedio/tsed",
54
54
  "devDependencies": {
55
55
  "@koa/cors": "5.0.0",
56
- "@tsed/barrels": "8.0.0-rc.5",
57
- "@tsed/core": "8.0.0-rc.5",
58
- "@tsed/di": "8.0.0-rc.5",
59
- "@tsed/platform-http": "8.0.0-rc.5",
60
- "@tsed/platform-test-sdk": "8.0.0-rc.5",
61
- "@tsed/typescript": "8.0.0-rc.5",
56
+ "@tsed/barrels": "8.0.0",
57
+ "@tsed/core": "8.0.0",
58
+ "@tsed/di": "8.0.0",
59
+ "@tsed/platform-http": "8.0.0",
60
+ "@tsed/platform-test-sdk": "8.0.0",
61
+ "@tsed/typescript": "8.0.0",
62
62
  "@types/koa": "2.15.0",
63
63
  "@types/koa-bodyparser": "4.3.12",
64
64
  "@types/koa-compose": "3.2.8",
@@ -86,13 +86,13 @@
86
86
  "tslib": "2.7.0"
87
87
  },
88
88
  "peerDependencies": {
89
- "@tsed/core": "8.0.0-rc.5",
90
- "@tsed/di": "8.0.0-rc.5",
91
- "@tsed/json-mapper": "8.0.0-rc.5",
89
+ "@tsed/core": "8.0.0",
90
+ "@tsed/di": "8.0.0",
91
+ "@tsed/json-mapper": "8.0.0",
92
92
  "@tsed/logger": ">=6.7.5",
93
- "@tsed/openspec": "8.0.0-rc.5",
94
- "@tsed/platform-http": "8.0.0-rc.5",
95
- "@tsed/schema": "8.0.0-rc.5",
93
+ "@tsed/openspec": "8.0.0",
94
+ "@tsed/platform-http": "8.0.0",
95
+ "@tsed/schema": "8.0.0",
96
96
  "cross-env": "7.0.3",
97
97
  "koa": ">=2.13.0",
98
98
  "koa-bodyparser": ">=4.3.0",
@@ -127,8 +127,5 @@
127
127
  "multer": {
128
128
  "optional": false
129
129
  }
130
- },
131
- "publishConfig": {
132
- "tag": "rc"
133
130
  }
134
131
  }
package/vitest.config.mts CHANGED
@@ -10,10 +10,10 @@ export default defineConfig(
10
10
  coverage: {
11
11
  ...presets.test.coverage,
12
12
  thresholds: {
13
- statements: 99.28,
14
- branches: 96.38,
13
+ statements: 99.15,
14
+ branches: 95.6,
15
15
  functions: 100,
16
- lines: 99.28
16
+ lines: 99.15
17
17
  }
18
18
  }
19
19
  }