@tsed/platform-koa 6.114.15 → 6.114.18

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.
package/jest.config.js ADDED
@@ -0,0 +1,14 @@
1
+ // For a detailed explanation regarding each configuration property, visit:
2
+ // https://jestjs.io/docs/en/configuration.html
3
+
4
+ module.exports = {
5
+ ...require("@tsed/jest-config")(__dirname, "platform-koa"),
6
+ coverageThreshold: {
7
+ global: {
8
+ statements: 99.51,
9
+ branches: 85.45,
10
+ functions: 100,
11
+ lines: 99.5
12
+ }
13
+ }
14
+ };
@@ -31,22 +31,23 @@ router_1.default.prototype.match = function match(...args) {
31
31
  * @koa
32
32
  */
33
33
  class PlatformKoa {
34
+ injector;
35
+ providers = [
36
+ {
37
+ provide: common_1.PlatformResponse,
38
+ useClass: PlatformKoaResponse_1.PlatformKoaResponse
39
+ },
40
+ {
41
+ provide: common_1.PlatformRequest,
42
+ useClass: PlatformKoaRequest_1.PlatformKoaRequest
43
+ },
44
+ {
45
+ provide: common_1.PlatformHandler,
46
+ useClass: PlatformKoaHandler_1.PlatformKoaHandler
47
+ }
48
+ ];
34
49
  constructor(injector) {
35
50
  this.injector = injector;
36
- this.providers = [
37
- {
38
- provide: common_1.PlatformResponse,
39
- useClass: PlatformKoaResponse_1.PlatformKoaResponse
40
- },
41
- {
42
- provide: common_1.PlatformRequest,
43
- useClass: PlatformKoaRequest_1.PlatformKoaRequest
44
- },
45
- {
46
- provide: common_1.PlatformHandler,
47
- useClass: PlatformKoaHandler_1.PlatformKoaHandler
48
- }
49
- ];
50
51
  }
51
52
  /**
52
53
  * Create new serverless application. In this mode, the component scan are disabled.
@@ -74,8 +75,7 @@ class PlatformKoa {
74
75
  const injector = this.injector;
75
76
  const app = this.injector.get(common_1.PlatformApplication);
76
77
  const listener = (error, ctx) => {
77
- var _a;
78
- (_a = injector.get(common_1.PlatformExceptions)) === null || _a === void 0 ? void 0 : _a.catch(error, ctx.request.$ctx);
78
+ injector.get(common_1.PlatformExceptions)?.catch(error, ctx.request.$ctx);
79
79
  };
80
80
  app.getApp().silent = true;
81
81
  app.getApp().on("error", listener);
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformKoa.js","sourceRoot":"","sources":["../../../src/components/PlatformKoa.ts"],"names":[],"mappings":";;;;AAAA,iEAAyE;AACzE,yCAasB;AACtB,qCAA4C;AAC5C,sDAAuC;AACvC,0FAAqF;AACrF,yEAAoE;AACpE,uEAAkE;AAClE,uEAAkE;AAClE,4CAA0C;AAC1C,wEAAmE;AAEnE,aAAa;AACb,4DAA2B;AAC3B,4EAAsD;AAgBtD,aAAa;AACb,gBAAS,CAAC,SAAS,CAAC,OAAO,GAAG,gBAAS,CAAC,SAAS,CAAC,KAAK,CAAC;AACxD,gBAAS,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;;;GAGG;AACH,MAAa,WAAW;IAgBtB,YAAoB,QAAyB;QAAzB,aAAQ,GAAR,QAAQ,CAAiB;QAfpC,cAAS,GAAG;YACnB;gBACE,OAAO,EAAE,yBAAgB;gBACzB,QAAQ,EAAE,yCAAmB;aAC9B;YACD;gBACE,OAAO,EAAE,wBAAe;gBACxB,QAAQ,EAAE,uCAAkB;aAC7B;YACD;gBACE,OAAO,EAAE,wBAAe;gBACxB,QAAQ,EAAE,uCAAkB;aAC7B;SACF,CAAC;IAE8C,CAAC;IAEjD;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,MAAiB,EAAE,WAAwC,EAAE;QACzE,OAAO,wBAAe,CAAC,MAAM,CAAiB,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AAC;YACpD,CAAC;SACF,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,OAA+B;QACvC,OAAO,IAAA,kBAAS,EAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,CAAC,QAAgB,EAAE,OAA+B;QACvD,OAAO,IAAA,qCAAiB,EAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,UAAU,CAAC,IAA4C,EAAE,oBAAyB,EAAE;QAClF,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC1D,IAAI,MAAM,GAAQ,wBAAa,CAAC;QAEhC,IAAI,OAAO,GAAY,EAAE,CAAC;QAE1B,IAAI,IAAA,iBAAU,EAAC,IAAI,CAAC,EAAE;YACpB,MAAM,GAAG,IAAI,CAAC;YACd,OAAO,GAAG,EAAE,CAAC;SACd;QAED,OAAO,MAAM,CAAC,EAAC,GAAG,OAAO,EAAE,GAAG,iBAAiB,EAAC,CAAC,CAAC;IACpD,CAAC;CACF;AAlID,kCAkIC","sourcesContent":["import KoaRouter, {RouterOptions as KoaRouterOptions} from \"@koa/router\";\nimport {\n createContext,\n InjectorService,\n PlatformAdapter,\n PlatformApplication,\n PlatformBuilder,\n PlatformExceptions,\n PlatformHandler,\n PlatformMulter,\n PlatformMulterSettings,\n PlatformRequest,\n PlatformResponse,\n PlatformStaticsOptions\n} from \"@tsed/common\";\nimport {isFunction, Type} from \"@tsed/core\";\nimport Koa, {Context, Next} from \"koa\";\nimport {resourceNotFoundMiddleware} from \"../middlewares/resourceNotFoundMiddleware\";\nimport {PlatformKoaResponse} from \"../services/PlatformKoaResponse\";\nimport {PlatformKoaRequest} from \"../services/PlatformKoaRequest\";\nimport {PlatformKoaHandler} from \"../services/PlatformKoaHandler\";\nimport {getMulter} from \"../utils/multer\";\nimport {staticsMiddleware} from \"../middlewares/staticsMiddleware\";\nimport send from \"koa-send\";\n// @ts-ignore\nimport koaQs from \"koa-qs\";\nimport koaBodyParser, {Options} from \"koa-bodyparser\";\n\ndeclare global {\n namespace TsED {\n export interface Application extends Koa {}\n }\n\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\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\n constructor(private injector: InjectorService) {}\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 = this.injector;\n const app = this.injector.get<PlatformApplication>(PlatformApplication)!;\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.injector.get<PlatformApplication<Koa>>(PlatformApplication)!;\n\n app.getApp().use(resourceNotFoundMiddleware);\n app.getApp().use(app.getRouter().routes()).use(app.getRouter().allowedMethods());\n\n return this;\n }\n\n useContext(): this {\n const app = this.injector.get<PlatformApplication<Koa>>(PlatformApplication)!;\n const {logger} = this.injector;\n logger.info(\"Mount app context\");\n\n const invoke = createContext(this.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 app() {\n const app = this.injector.settings.get(\"koa.app\") || new Koa();\n koaQs(app, \"extended\");\n\n return {\n app,\n callback() {\n return app.callback();\n }\n };\n }\n\n router(routerOptions: any = {}) {\n const {settings} = this.injector;\n\n const options = Object.assign({}, settings.get(\"koa.router\", {}), routerOptions);\n const router = new KoaRouter(options) as any;\n\n return {\n router,\n callback() {\n return [router.routes(), router.allowedMethods()];\n }\n };\n }\n\n multipart(options: PlatformMulterSettings): PlatformMulter {\n return getMulter(options);\n }\n\n statics(endpoint: string, options: PlatformStaticsOptions) {\n return staticsMiddleware(options);\n }\n\n bodyParser(type: \"json\" | \"urlencoded\" | \"raw\" | \"text\", additionalOptions: any = {}): any {\n const opts = this.injector.settings.get(`koa.bodyParser`);\n let parser: any = koaBodyParser;\n\n let options: Options = {};\n\n if (isFunction(opts)) {\n parser = opts;\n options = {};\n }\n\n return parser({...options, ...additionalOptions});\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformKoa.js","sourceRoot":"","sources":["../../../src/components/PlatformKoa.ts"],"names":[],"mappings":";;;;AAAA,iEAAyE;AACzE,yCAasB;AACtB,qCAA4C;AAC5C,sDAAuC;AACvC,0FAAqF;AACrF,yEAAoE;AACpE,uEAAkE;AAClE,uEAAkE;AAClE,4CAA0C;AAC1C,wEAAmE;AAEnE,aAAa;AACb,4DAA2B;AAC3B,4EAAsD;AAgBtD,aAAa;AACb,gBAAS,CAAC,SAAS,CAAC,OAAO,GAAG,gBAAS,CAAC,SAAS,CAAC,KAAK,CAAC;AACxD,gBAAS,CAAC,SAAS,CAAC,KAAK,GAAG,SAAS,KAAK,CAAC,GAAG,IA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,OAAO,MAAM,CAAC,EAAC,GAAG,OAAO,EAAE,GAAG,iBAAiB,EAAC,CAAC,CAAC;IACpD,CAAC;CACF;AAlID,kCAkIC","sourcesContent":["import KoaRouter, {RouterOptions as KoaRouterOptions} from \"@koa/router\";\nimport {\n createContext,\n InjectorService,\n PlatformAdapter,\n PlatformApplication,\n PlatformBuilder,\n PlatformExceptions,\n PlatformHandler,\n PlatformMulter,\n PlatformMulterSettings,\n PlatformRequest,\n PlatformResponse,\n PlatformStaticsOptions\n} from \"@tsed/common\";\nimport {isFunction, Type} from \"@tsed/core\";\nimport Koa, {Context, Next} from \"koa\";\nimport {resourceNotFoundMiddleware} from \"../middlewares/resourceNotFoundMiddleware\";\nimport {PlatformKoaResponse} from \"../services/PlatformKoaResponse\";\nimport {PlatformKoaRequest} from \"../services/PlatformKoaRequest\";\nimport {PlatformKoaHandler} from \"../services/PlatformKoaHandler\";\nimport {getMulter} from \"../utils/multer\";\nimport {staticsMiddleware} from \"../middlewares/staticsMiddleware\";\nimport send from \"koa-send\";\n// @ts-ignore\nimport koaQs from \"koa-qs\";\nimport koaBodyParser, {Options} from \"koa-bodyparser\";\n\ndeclare global {\n namespace TsED {\n export interface Application extends Koa {}\n }\n\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\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\n constructor(private injector: InjectorService) {}\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 = this.injector;\n const app = this.injector.get<PlatformApplication>(PlatformApplication)!;\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.injector.get<PlatformApplication<Koa>>(PlatformApplication)!;\n\n app.getApp().use(resourceNotFoundMiddleware);\n app.getApp().use(app.getRouter().routes()).use(app.getRouter().allowedMethods());\n\n return this;\n }\n\n useContext(): this {\n const app = this.injector.get<PlatformApplication<Koa>>(PlatformApplication)!;\n const {logger} = this.injector;\n logger.info(\"Mount app context\");\n\n const invoke = createContext(this.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 app() {\n const app = this.injector.settings.get(\"koa.app\") || new Koa();\n koaQs(app, \"extended\");\n\n return {\n app,\n callback() {\n return app.callback();\n }\n };\n }\n\n router(routerOptions: any = {}) {\n const {settings} = this.injector;\n\n const options = Object.assign({}, settings.get(\"koa.router\", {}), routerOptions);\n const router = new KoaRouter(options) as any;\n\n return {\n router,\n callback() {\n return [router.routes(), router.allowedMethods()];\n }\n };\n }\n\n multipart(options: PlatformMulterSettings): PlatformMulter {\n return getMulter(options);\n }\n\n statics(endpoint: string, options: PlatformStaticsOptions) {\n return staticsMiddleware(options);\n }\n\n bodyParser(type: \"json\" | \"urlencoded\" | \"raw\" | \"text\", additionalOptions: any = {}): any {\n const opts = this.injector.settings.get(`koa.bodyParser`);\n let parser: any = koaBodyParser;\n\n let options: Options = {};\n\n if (isFunction(opts)) {\n parser = opts;\n options = {};\n }\n\n return parser({...options, ...additionalOptions});\n }\n}\n"]}
@@ -8,12 +8,11 @@ const common_1 = require("@tsed/common");
8
8
  * @param next
9
9
  */
10
10
  async function resourceNotFoundMiddleware(ctx, next) {
11
- var _a;
12
11
  const $ctx = ctx.request.$ctx;
13
12
  await next();
14
13
  const status = ctx.status || 404;
15
14
  if (status === 404 && !$ctx.isDone()) {
16
- (_a = $ctx.injector.get(common_1.PlatformExceptions)) === null || _a === void 0 ? void 0 : _a.resourceNotFound($ctx);
15
+ $ctx.injector.get(common_1.PlatformExceptions)?.resourceNotFound($ctx);
17
16
  }
18
17
  }
19
18
  exports.resourceNotFoundMiddleware = resourceNotFoundMiddleware;
@@ -1 +1 @@
1
- {"version":3,"file":"resourceNotFoundMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/resourceNotFoundMiddleware.ts"],"names":[],"mappings":";;;AAAA,yCAAiE;AAEjE;;;;GAIG;AACI,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,2BAAkB,CAAC,0CAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC;KACnF;AACH,CAAC;AARD,gEAQC","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
+ {"version":3,"file":"resourceNotFoundMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/resourceNotFoundMiddleware.ts"],"names":[],"mappings":";;;AAAA,yCAAiE;AAEjE;;;;GAIG;AACI,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,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAqB,2BAAkB,CAAC,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC;KACnF;AACH,CAAC;AARD,gEAQC","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,8 +1,6 @@
1
1
  "use strict";
2
- var _PlatformKoaRequest_ctx;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.PlatformKoaRequest = void 0;
5
- const tslib_1 = require("tslib");
6
4
  require("@koa/router");
7
5
  const common_1 = require("@tsed/common");
8
6
  /**
@@ -10,35 +8,34 @@ const common_1 = require("@tsed/common");
10
8
  * @koa
11
9
  */
12
10
  class PlatformKoaRequest extends common_1.PlatformRequest {
11
+ #ctx;
13
12
  constructor(event, $ctx) {
14
13
  super(event, $ctx);
15
- _PlatformKoaRequest_ctx.set(this, void 0);
16
- tslib_1.__classPrivateFieldSet(this, _PlatformKoaRequest_ctx, this.raw.ctx, "f");
14
+ this.#ctx = this.raw.ctx;
17
15
  }
18
16
  get protocol() {
19
- return tslib_1.__classPrivateFieldGet(this, _PlatformKoaRequest_ctx, "f").request.protocol;
17
+ return this.#ctx.request.protocol;
20
18
  }
21
19
  get host() {
22
- return tslib_1.__classPrivateFieldGet(this, _PlatformKoaRequest_ctx, "f").request.host;
20
+ return this.#ctx.request.host;
23
21
  }
24
22
  get secure() {
25
- return tslib_1.__classPrivateFieldGet(this, _PlatformKoaRequest_ctx, "f").request.secure;
23
+ return this.#ctx.request.secure;
26
24
  }
27
25
  get cookies() {
28
- return tslib_1.__classPrivateFieldGet(this, _PlatformKoaRequest_ctx, "f").cookie || tslib_1.__classPrivateFieldGet(this, _PlatformKoaRequest_ctx, "f").cookies;
26
+ return this.#ctx.cookie || this.#ctx.cookies;
29
27
  }
30
28
  get session() {
31
- return tslib_1.__classPrivateFieldGet(this, _PlatformKoaRequest_ctx, "f").session;
29
+ return this.#ctx.session;
32
30
  }
33
31
  getReq() {
34
32
  return this.raw.req;
35
33
  }
36
34
  destroy() {
37
35
  // @ts-ignore
38
- tslib_1.__classPrivateFieldSet(this, _PlatformKoaRequest_ctx, null, "f");
36
+ this.#ctx = null;
39
37
  return super.destroy();
40
38
  }
41
39
  }
42
40
  exports.PlatformKoaRequest = PlatformKoaRequest;
43
- _PlatformKoaRequest_ctx = new WeakMap();
44
41
  //# sourceMappingURL=PlatformKoaRequest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformKoaRequest.js","sourceRoot":"","sources":["../../../src/services/PlatformKoaRequest.ts"],"names":[],"mappings":";;;;;AAAA,uBAAqB;AACrB,yCAA6E;AAiB7E;;;GAGG;AACH,MAAa,kBAAmB,SAAQ,wBAA4B;IAGlE,YAAY,KAAoB,EAAE,IAAqB;QACrD,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAHrB,0CAAkB;QAIhB,+BAAA,IAAI,2BAAQ,IAAI,CAAC,GAAG,CAAC,GAAG,MAAA,CAAC;IAC3B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,+BAAA,IAAI,+BAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;IACpC,CAAC;IAED,IAAI,IAAI;QACN,OAAO,+BAAA,IAAI,+BAAK,CAAC,OAAO,CAAC,IAAI,CAAC;IAChC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,+BAAA,IAAI,+BAAK,CAAC,OAAO,CAAC,MAAM,CAAC;IAClC,CAAC;IAED,IAAI,OAAO;QACT,OAAO,+BAAA,IAAI,+BAAK,CAAC,MAAM,IAAI,+BAAA,IAAI,+BAAK,CAAC,OAAO,CAAC;IAC/C,CAAC;IAED,IAAI,OAAO;QACT,OAAO,+BAAA,IAAI,+BAAK,CAAC,OAAO,CAAC;IAC3B,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACtB,CAAC;IAED,OAAO;QACL,aAAa;QACb,+BAAA,IAAI,2BAAQ,IAAI,MAAA,CAAC;QACjB,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;CACF;AArCD,gDAqCC","sourcesContent":["import \"@koa/router\";\nimport {IncomingEvent, PlatformContext, PlatformRequest} from \"@tsed/common\";\nimport {IncomingMessage} from \"http\";\nimport Koa from \"koa\";\n\ndeclare module \"koa\" {\n export interface Request {\n id: string;\n $ctx: PlatformContext;\n }\n}\n\ndeclare global {\n namespace TsED {\n export interface Request extends Koa.Request {}\n }\n}\n\n/**\n * @platform\n * @koa\n */\nexport class PlatformKoaRequest extends PlatformRequest<Koa.Request> {\n #ctx: Koa.Context;\n\n constructor(event: IncomingEvent, $ctx: PlatformContext) {\n super(event, $ctx);\n this.#ctx = this.raw.ctx;\n }\n\n get protocol(): string {\n return this.#ctx.request.protocol;\n }\n\n get host(): string {\n return this.#ctx.request.host;\n }\n\n get secure(): boolean {\n return this.#ctx.request.secure;\n }\n\n get cookies(): {[p: string]: any} {\n return this.#ctx.cookie || this.#ctx.cookies;\n }\n\n get session(): any {\n return this.#ctx.session;\n }\n\n getReq(): IncomingMessage {\n return this.raw.req;\n }\n\n destroy() {\n // @ts-ignore\n this.#ctx = null;\n return super.destroy();\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformKoaRequest.js","sourceRoot":"","sources":["../../../src/services/PlatformKoaRequest.ts"],"names":[],"mappings":";;;AAAA,uBAAqB;AACrB,yCAA6E;AAiB7E;;;GAGG;AACH,MAAa,kBAAmB,SAAQ,wBAA4B;IAClE,IAAI,CAAc;IAElB,YAAY,KAAoB,EAAE,IAAqB;QACrD,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAC3B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IACpC,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAChC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAClC,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IAC/C,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IAC3B,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACtB,CAAC;IAED,OAAO;QACL,aAAa;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;CACF;AArCD,gDAqCC","sourcesContent":["import \"@koa/router\";\nimport {IncomingEvent, PlatformContext, PlatformRequest} from \"@tsed/common\";\nimport {IncomingMessage} from \"http\";\nimport Koa from \"koa\";\n\ndeclare module \"koa\" {\n export interface Request {\n id: string;\n $ctx: PlatformContext;\n }\n}\n\ndeclare global {\n namespace TsED {\n export interface Request extends Koa.Request {}\n }\n}\n\n/**\n * @platform\n * @koa\n */\nexport class PlatformKoaRequest extends PlatformRequest<Koa.Request> {\n #ctx: Koa.Context;\n\n constructor(event: IncomingEvent, $ctx: PlatformContext) {\n super(event, $ctx);\n this.#ctx = this.raw.ctx;\n }\n\n get protocol(): string {\n return this.#ctx.request.protocol;\n }\n\n get host(): string {\n return this.#ctx.request.host;\n }\n\n get secure(): boolean {\n return this.#ctx.request.secure;\n }\n\n get cookies(): {[p: string]: any} {\n return this.#ctx.cookie || this.#ctx.cookies;\n }\n\n get session(): any {\n return this.#ctx.session;\n }\n\n getReq(): IncomingMessage {\n return this.raw.req;\n }\n\n destroy() {\n // @ts-ignore\n this.#ctx = null;\n return super.destroy();\n }\n}\n"]}
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- var _PlatformKoaResponse_ctx;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.PlatformKoaResponse = void 0;
5
4
  const tslib_1 = require("tslib");
@@ -11,16 +10,16 @@ const encodeurl_1 = tslib_1.__importDefault(require("encodeurl"));
11
10
  * @koa
12
11
  */
13
12
  class PlatformKoaResponse extends common_1.PlatformResponse {
13
+ #ctx;
14
14
  constructor(event, $ctx) {
15
15
  super(event, $ctx);
16
- _PlatformKoaResponse_ctx.set(this, void 0);
17
- tslib_1.__classPrivateFieldSet(this, _PlatformKoaResponse_ctx, this.raw.ctx, "f");
16
+ this.#ctx = this.raw.ctx;
18
17
  }
19
18
  get statusCode() {
20
19
  return this.raw.status;
21
20
  }
22
21
  get locals() {
23
- return tslib_1.__classPrivateFieldGet(this, _PlatformKoaResponse_ctx, "f").state;
22
+ return this.#ctx.state;
24
23
  }
25
24
  /**
26
25
  * Return the Node.js response object
@@ -101,5 +100,4 @@ class PlatformKoaResponse extends common_1.PlatformResponse {
101
100
  }
102
101
  }
103
102
  exports.PlatformKoaResponse = PlatformKoaResponse;
104
- _PlatformKoaResponse_ctx = new WeakMap();
105
103
  //# sourceMappingURL=PlatformKoaResponse.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformKoaResponse.js","sourceRoot":"","sources":["../../../src/services/PlatformKoaResponse.ts"],"names":[],"mappings":";;;;;AAAA,yCAA8E;AAG9E,yCAA8C;AAC9C,kEAAkC;AAQlC;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,yBAA8B;IAGrE,YAAY,KAAoB,EAAE,IAAqB;QACrD,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAHrB,2CAAkB;QAIhB,+BAAA,IAAI,4BAAQ,IAAI,CAAC,GAAG,CAAC,GAAG,MAAA,CAAC;IAC3B,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;IACzB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,+BAAA,IAAI,gCAAK,CAAC,KAAK,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACtB,CAAC;IAED,SAAS;QACP,yBAAyB;QACzB,OAAO,IAAI,CAAC,UAAU,KAAK,GAAG,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,MAAc;QACnB,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;QAEzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;OAWG;IACH,WAAW,CAAC,WA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AAG,CAAC;SAChD;QAED,eAAe;QACf,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,IAAA,mBAAS,EAAC,QAAQ,CAAC,CAAC,CAAC;QAE9C,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA5GD,kDA4GC","sourcesContent":["import {IncomingEvent, PlatformContext, PlatformResponse} from \"@tsed/common\";\nimport {ServerResponse} from \"http\";\nimport Koa from \"koa\";\nimport {getStatusMessage} from \"@tsed/schema\";\nimport encodeUrl from \"encodeurl\";\n\ndeclare global {\n namespace TsED {\n export interface Response extends Koa.Response {}\n }\n}\n\n/**\n * @platform\n * @koa\n */\nexport class PlatformKoaResponse extends PlatformResponse<Koa.Response> {\n #ctx: Koa.Context;\n\n constructor(event: IncomingEvent, $ctx: PlatformContext) {\n super(event, $ctx);\n this.#ctx = this.raw.ctx;\n }\n\n get statusCode() {\n return this.raw.status;\n }\n\n get locals() {\n return this.#ctx.state;\n }\n\n /**\n * Return the Node.js response object\n */\n getRes(): ServerResponse {\n return this.raw.res;\n }\n\n hasStatus() {\n // KOA set 404 by default\n return this.statusCode !== 404;\n }\n\n /**\n * Sets the HTTP status for the response.\n *\n * @param status\n */\n status(status: number) {\n this.raw.status = status;\n\n return this;\n }\n\n /**\n * Set `Content-Type` response header with `type` through `mime.lookup()`\n * when it does not contain \"/\", or set the Content-Type to `type` otherwise.\n *\n * Examples:\n *\n * res.type('.html');\n * res.type('html');\n * res.type('json');\n * res.type('application/json');\n * res.type('png');\n */\n contentType(contentType: string) {\n this.raw.type = contentType;\n\n return this;\n }\n\n getHeaders() {\n return this.raw.headers;\n }\n\n /**\n * Send any data to your consumer.\n *\n * This method accept a ReadableStream, a plain object, boolean, string, number, null and undefined data.\n * It choose the better way to send the data.\n *\n * @param data\n */\n body(data: any): this {\n this.raw.body = data;\n\n return this;\n }\n\n getBody(): any {\n return this.raw.body;\n }\n\n redirect(status: number, url: string): this {\n status = status || 302;\n // Set location header\n url = this.location(url).raw.get(\"Location\");\n\n this.body(`${getStatusMessage(status)}. Redirecting to ${url}`);\n this.status(status);\n this.setHeader(\"Content-Length\", Buffer.byteLength(this.raw.body as any));\n\n if (this.request.method === \"HEAD\") {\n this.getRes().end();\n } else {\n this.getRes().end(this.getBody());\n }\n\n return this;\n }\n\n location(location: string): this {\n // \"back\" is an alias for the referrer\n if (location === \"back\") {\n location = this.request.get(\"Referrer\") || \"/\";\n }\n\n // set location\n this.raw.set(\"Location\", encodeUrl(location));\n\n return this;\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformKoaResponse.js","sourceRoot":"","sources":["../../../src/services/PlatformKoaResponse.ts"],"names":[],"mappings":";;;;AAAA,yCAA8E;AAG9E,yCAA8C;AAC9C,kEAAkC;AAQlC;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,yBAA8B;IACrE,IAAI,CAAc;IAElB,YAAY,KAAoB,EAAE,IAAqB;QACrD,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAC3B,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;IACzB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACtB,CAAC;IAED,SAAS;QACP,yBAAyB;QACzB,OAAO,IAAI,CAAC,UAAU,KAAK,GAAG,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,MAAc;QACnB,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;QAEzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;OAWG;IACH,WAAW,CAAC,WAAmB;QAC7B,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,WAAW,CA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GAAG,CAAC,UAAU,EAAE,IAAA,mBAAS,EAAC,QAAQ,CAAC,CAAC,CAAC;QAE9C,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA5GD,kDA4GC","sourcesContent":["import {IncomingEvent, PlatformContext, PlatformResponse} from \"@tsed/common\";\nimport {ServerResponse} from \"http\";\nimport Koa from \"koa\";\nimport {getStatusMessage} from \"@tsed/schema\";\nimport encodeUrl from \"encodeurl\";\n\ndeclare global {\n namespace TsED {\n export interface Response extends Koa.Response {}\n }\n}\n\n/**\n * @platform\n * @koa\n */\nexport class PlatformKoaResponse extends PlatformResponse<Koa.Response> {\n #ctx: Koa.Context;\n\n constructor(event: IncomingEvent, $ctx: PlatformContext) {\n super(event, $ctx);\n this.#ctx = this.raw.ctx;\n }\n\n get statusCode() {\n return this.raw.status;\n }\n\n get locals() {\n return this.#ctx.state;\n }\n\n /**\n * Return the Node.js response object\n */\n getRes(): ServerResponse {\n return this.raw.res;\n }\n\n hasStatus() {\n // KOA set 404 by default\n return this.statusCode !== 404;\n }\n\n /**\n * Sets the HTTP status for the response.\n *\n * @param status\n */\n status(status: number) {\n this.raw.status = status;\n\n return this;\n }\n\n /**\n * Set `Content-Type` response header with `type` through `mime.lookup()`\n * when it does not contain \"/\", or set the Content-Type to `type` otherwise.\n *\n * Examples:\n *\n * res.type('.html');\n * res.type('html');\n * res.type('json');\n * res.type('application/json');\n * res.type('png');\n */\n contentType(contentType: string) {\n this.raw.type = contentType;\n\n return this;\n }\n\n getHeaders() {\n return this.raw.headers;\n }\n\n /**\n * Send any data to your consumer.\n *\n * This method accept a ReadableStream, a plain object, boolean, string, number, null and undefined data.\n * It choose the better way to send the data.\n *\n * @param data\n */\n body(data: any): this {\n this.raw.body = data;\n\n return this;\n }\n\n getBody(): any {\n return this.raw.body;\n }\n\n redirect(status: number, url: string): this {\n status = status || 302;\n // Set location header\n url = this.location(url).raw.get(\"Location\");\n\n this.body(`${getStatusMessage(status)}. Redirecting to ${url}`);\n this.status(status);\n this.setHeader(\"Content-Length\", Buffer.byteLength(this.raw.body as any));\n\n if (this.request.method === \"HEAD\") {\n this.getRes().end();\n } else {\n this.getRes().end(this.getBody());\n }\n\n return this;\n }\n\n location(location: string): this {\n // \"back\" is an alias for the referrer\n if (location === \"back\") {\n location = this.request.get(\"Referrer\") || \"/\";\n }\n\n // set location\n this.raw.set(\"Location\", encodeUrl(location));\n\n return this;\n }\n}\n"]}
@@ -27,22 +27,23 @@ KoaRouter.prototype.match = function match(...args) {
27
27
  * @koa
28
28
  */
29
29
  export class PlatformKoa {
30
+ injector;
31
+ providers = [
32
+ {
33
+ provide: PlatformResponse,
34
+ useClass: PlatformKoaResponse
35
+ },
36
+ {
37
+ provide: PlatformRequest,
38
+ useClass: PlatformKoaRequest
39
+ },
40
+ {
41
+ provide: PlatformHandler,
42
+ useClass: PlatformKoaHandler
43
+ }
44
+ ];
30
45
  constructor(injector) {
31
46
  this.injector = injector;
32
- this.providers = [
33
- {
34
- provide: PlatformResponse,
35
- useClass: PlatformKoaResponse
36
- },
37
- {
38
- provide: PlatformRequest,
39
- useClass: PlatformKoaRequest
40
- },
41
- {
42
- provide: PlatformHandler,
43
- useClass: PlatformKoaHandler
44
- }
45
- ];
46
47
  }
47
48
  /**
48
49
  * Create new serverless application. In this mode, the component scan are disabled.
@@ -70,8 +71,7 @@ export class PlatformKoa {
70
71
  const injector = this.injector;
71
72
  const app = this.injector.get(PlatformApplication);
72
73
  const listener = (error, ctx) => {
73
- var _a;
74
- (_a = injector.get(PlatformExceptions)) === null || _a === void 0 ? void 0 : _a.catch(error, ctx.request.$ctx);
74
+ injector.get(PlatformExceptions)?.catch(error, ctx.request.$ctx);
75
75
  };
76
76
  app.getApp().silent = true;
77
77
  app.getApp().on("error", listener);
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformKoa.js","sourceRoot":"","sources":["../../../src/components/PlatformKoa.ts"],"names":[],"mappings":"AAAA,OAAO,SAA8C,MAAM,aAAa,CAAC;AACzE,OAAO,EAC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,EAAE,aAAa,CAAC,CAAC;QACjF,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,OAAO,CAAQ,CAAC;QAE7C,OAAO;YACL,MAAM;YACN,QAAQ;gBACN,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;YACpD,CAAC;SACF,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,OAA+B;QACvC,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,CAAC,QAAgB,EAAE,OAA+B;QACvD,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,UAAU,CAAC,IAA4C,EAAE,oBAAyB,EAAE;QAClF,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC1D,IAAI,MAAM,GAAQ,aAAa,CAAC;QAEhC,IAAI,OAAO,GAAY,EAAE,CAAC;QAE1B,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE;YACpB,MAAM,GAAG,IAAI,CAAC;YACd,OAAO,GAAG,EAAE,CAAC;SACd;QAED,OAAO,MAAM,CAAC,EAAC,GAAG,OAAO,EAAE,GAAG,iBAAiB,EAAC,CAAC,CAAC;IACpD,CAAC;CACF","sourcesContent":["import KoaRouter, {RouterOptions as KoaRouterOptions} from \"@koa/router\";\nimport {\n createContext,\n InjectorService,\n PlatformAdapter,\n PlatformApplication,\n PlatformBuilder,\n PlatformExceptions,\n PlatformHandler,\n PlatformMulter,\n PlatformMulterSettings,\n PlatformRequest,\n PlatformResponse,\n PlatformStaticsOptions\n} from \"@tsed/common\";\nimport {isFunction, Type} from \"@tsed/core\";\nimport Koa, {Context, Next} from \"koa\";\nimport {resourceNotFoundMiddleware} from \"../middlewares/resourceNotFoundMiddleware\";\nimport {PlatformKoaResponse} from \"../services/PlatformKoaResponse\";\nimport {PlatformKoaRequest} from \"../services/PlatformKoaRequest\";\nimport {PlatformKoaHandler} from \"../services/PlatformKoaHandler\";\nimport {getMulter} from \"../utils/multer\";\nimport {staticsMiddleware} from \"../middlewares/staticsMiddleware\";\nimport send from \"koa-send\";\n// @ts-ignore\nimport koaQs from \"koa-qs\";\nimport koaBodyParser, {Options} from \"koa-bodyparser\";\n\ndeclare global {\n namespace TsED {\n export interface Application extends Koa {}\n }\n\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\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\n constructor(private injector: InjectorService) {}\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 = this.injector;\n const app = this.injector.get<PlatformApplication>(PlatformApplication)!;\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.injector.get<PlatformApplication<Koa>>(PlatformApplication)!;\n\n app.getApp().use(resourceNotFoundMiddleware);\n app.getApp().use(app.getRouter().routes()).use(app.getRouter().allowedMethods());\n\n return this;\n }\n\n useContext(): this {\n const app = this.injector.get<PlatformApplication<Koa>>(PlatformApplication)!;\n const {logger} = this.injector;\n logger.info(\"Mount app context\");\n\n const invoke = createContext(this.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 app() {\n const app = this.injector.settings.get(\"koa.app\") || new Koa();\n koaQs(app, \"extended\");\n\n return {\n app,\n callback() {\n return app.callback();\n }\n };\n }\n\n router(routerOptions: any = {}) {\n const {settings} = this.injector;\n\n const options = Object.assign({}, settings.get(\"koa.router\", {}), routerOptions);\n const router = new KoaRouter(options) as any;\n\n return {\n router,\n callback() {\n return [router.routes(), router.allowedMethods()];\n }\n };\n }\n\n multipart(options: PlatformMulterSettings): PlatformMulter {\n return getMulter(options);\n }\n\n statics(endpoint: string, options: PlatformStaticsOptions) {\n return staticsMiddleware(options);\n }\n\n bodyParser(type: \"json\" | \"urlencoded\" | \"raw\" | \"text\", additionalOptions: any = {}): any {\n const opts = this.injector.settings.get(`koa.bodyParser`);\n let parser: any = koaBodyParser;\n\n let options: Options = {};\n\n if (isFunction(opts)) {\n parser = opts;\n options = {};\n }\n\n return parser({...options, ...additionalOptions});\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformKoa.js","sourceRoot":"","sources":["../../../src/components/PlatformKoa.ts"],"names":[],"mappings":"AAAA,OAAO,SAA8C,MAAM,aAAa,CAAC;AACzE,OAAO,EACL,aAAa,EAGb,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,eAAe,EAGf,eAAe,EACf,gBAAgB,EAEjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,UAAU,EA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C,MAAM,EAAE,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;YACpD,CAAC;SACF,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,OAA+B;QACvC,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,CAAC,QAAgB,EAAE,OAA+B;QACvD,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,UAAU,CAAC,IAA4C,EAAE,oBAAyB,EAAE;QAClF,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC1D,IAAI,MAAM,GAAQ,aAAa,CAAC;QAEhC,IAAI,OAAO,GAAY,EAAE,CAAC;QAE1B,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE;YACpB,MAAM,GAAG,IAAI,CAAC;YACd,OAAO,GAAG,EAAE,CAAC;SACd;QAED,OAAO,MAAM,CAAC,EAAC,GAAG,OAAO,EAAE,GAAG,iBAAiB,EAAC,CAAC,CAAC;IACpD,CAAC;CACF","sourcesContent":["import KoaRouter, {RouterOptions as KoaRouterOptions} from \"@koa/router\";\nimport {\n createContext,\n InjectorService,\n PlatformAdapter,\n PlatformApplication,\n PlatformBuilder,\n PlatformExceptions,\n PlatformHandler,\n PlatformMulter,\n PlatformMulterSettings,\n PlatformRequest,\n PlatformResponse,\n PlatformStaticsOptions\n} from \"@tsed/common\";\nimport {isFunction, Type} from \"@tsed/core\";\nimport Koa, {Context, Next} from \"koa\";\nimport {resourceNotFoundMiddleware} from \"../middlewares/resourceNotFoundMiddleware\";\nimport {PlatformKoaResponse} from \"../services/PlatformKoaResponse\";\nimport {PlatformKoaRequest} from \"../services/PlatformKoaRequest\";\nimport {PlatformKoaHandler} from \"../services/PlatformKoaHandler\";\nimport {getMulter} from \"../utils/multer\";\nimport {staticsMiddleware} from \"../middlewares/staticsMiddleware\";\nimport send from \"koa-send\";\n// @ts-ignore\nimport koaQs from \"koa-qs\";\nimport koaBodyParser, {Options} from \"koa-bodyparser\";\n\ndeclare global {\n namespace TsED {\n export interface Application extends Koa {}\n }\n\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\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\n constructor(private injector: InjectorService) {}\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 = this.injector;\n const app = this.injector.get<PlatformApplication>(PlatformApplication)!;\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.injector.get<PlatformApplication<Koa>>(PlatformApplication)!;\n\n app.getApp().use(resourceNotFoundMiddleware);\n app.getApp().use(app.getRouter().routes()).use(app.getRouter().allowedMethods());\n\n return this;\n }\n\n useContext(): this {\n const app = this.injector.get<PlatformApplication<Koa>>(PlatformApplication)!;\n const {logger} = this.injector;\n logger.info(\"Mount app context\");\n\n const invoke = createContext(this.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 app() {\n const app = this.injector.settings.get(\"koa.app\") || new Koa();\n koaQs(app, \"extended\");\n\n return {\n app,\n callback() {\n return app.callback();\n }\n };\n }\n\n router(routerOptions: any = {}) {\n const {settings} = this.injector;\n\n const options = Object.assign({}, settings.get(\"koa.router\", {}), routerOptions);\n const router = new KoaRouter(options) as any;\n\n return {\n router,\n callback() {\n return [router.routes(), router.allowedMethods()];\n }\n };\n }\n\n multipart(options: PlatformMulterSettings): PlatformMulter {\n return getMulter(options);\n }\n\n statics(endpoint: string, options: PlatformStaticsOptions) {\n return staticsMiddleware(options);\n }\n\n bodyParser(type: \"json\" | \"urlencoded\" | \"raw\" | \"text\", additionalOptions: any = {}): any {\n const opts = this.injector.settings.get(`koa.bodyParser`);\n let parser: any = koaBodyParser;\n\n let options: Options = {};\n\n if (isFunction(opts)) {\n parser = opts;\n options = {};\n }\n\n return parser({...options, ...additionalOptions});\n }\n}\n"]}
@@ -5,12 +5,11 @@ import { PlatformExceptions } from "@tsed/common";
5
5
  * @param next
6
6
  */
7
7
  export async function resourceNotFoundMiddleware(ctx, next) {
8
- var _a;
9
8
  const $ctx = ctx.request.$ctx;
10
9
  await next();
11
10
  const status = ctx.status || 404;
12
11
  if (status === 404 && !$ctx.isDone()) {
13
- (_a = $ctx.injector.get(PlatformExceptions)) === null || _a === void 0 ? void 0 : _a.resourceNotFound($ctx);
12
+ $ctx.injector.get(PlatformExceptions)?.resourceNotFound($ctx);
14
13
  }
15
14
  }
16
15
  //# sourceMappingURL=resourceNotFoundMiddleware.js.map
@@ -1 +1 @@
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
+ {"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,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAqB,kBAAkB,CAAC,EAAE,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,5 +1,3 @@
1
- var _PlatformKoaRequest_ctx;
2
- import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
1
  import "@koa/router";
4
2
  import { PlatformRequest } from "@tsed/common";
5
3
  /**
@@ -7,34 +5,33 @@ import { PlatformRequest } from "@tsed/common";
7
5
  * @koa
8
6
  */
9
7
  export class PlatformKoaRequest extends PlatformRequest {
8
+ #ctx;
10
9
  constructor(event, $ctx) {
11
10
  super(event, $ctx);
12
- _PlatformKoaRequest_ctx.set(this, void 0);
13
- __classPrivateFieldSet(this, _PlatformKoaRequest_ctx, this.raw.ctx, "f");
11
+ this.#ctx = this.raw.ctx;
14
12
  }
15
13
  get protocol() {
16
- return __classPrivateFieldGet(this, _PlatformKoaRequest_ctx, "f").request.protocol;
14
+ return this.#ctx.request.protocol;
17
15
  }
18
16
  get host() {
19
- return __classPrivateFieldGet(this, _PlatformKoaRequest_ctx, "f").request.host;
17
+ return this.#ctx.request.host;
20
18
  }
21
19
  get secure() {
22
- return __classPrivateFieldGet(this, _PlatformKoaRequest_ctx, "f").request.secure;
20
+ return this.#ctx.request.secure;
23
21
  }
24
22
  get cookies() {
25
- return __classPrivateFieldGet(this, _PlatformKoaRequest_ctx, "f").cookie || __classPrivateFieldGet(this, _PlatformKoaRequest_ctx, "f").cookies;
23
+ return this.#ctx.cookie || this.#ctx.cookies;
26
24
  }
27
25
  get session() {
28
- return __classPrivateFieldGet(this, _PlatformKoaRequest_ctx, "f").session;
26
+ return this.#ctx.session;
29
27
  }
30
28
  getReq() {
31
29
  return this.raw.req;
32
30
  }
33
31
  destroy() {
34
32
  // @ts-ignore
35
- __classPrivateFieldSet(this, _PlatformKoaRequest_ctx, null, "f");
33
+ this.#ctx = null;
36
34
  return super.destroy();
37
35
  }
38
36
  }
39
- _PlatformKoaRequest_ctx = new WeakMap();
40
37
  //# sourceMappingURL=PlatformKoaRequest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformKoaRequest.js","sourceRoot":"","sources":["../../../src/services/PlatformKoaRequest.ts"],"names":[],"mappings":";;AAAA,OAAO,aAAa,CAAC;AACrB,OAAO,EAAiC,eAAe,EAAC,MAAM,cAAc,CAAC;AAiB7E;;;GAGG;AACH,MAAM,OAAO,kBAAmB,SAAQ,eAA4B;IAGlE,YAAY,KAAoB,EAAE,IAAqB;QACrD,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAHrB,0CAAkB;QAIhB,uBAAA,IAAI,2BAAQ,IAAI,CAAC,GAAG,CAAC,GAAG,MAAA,CAAC;IAC3B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,uBAAA,IAAI,+BAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;IACpC,CAAC;IAED,IAAI,IAAI;QACN,OAAO,uBAAA,IAAI,+BAAK,CAAC,OAAO,CAAC,IAAI,CAAC;IAChC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,uBAAA,IAAI,+BAAK,CAAC,OAAO,CAAC,MAAM,CAAC;IAClC,CAAC;IAED,IAAI,OAAO;QACT,OAAO,uBAAA,IAAI,+BAAK,CAAC,MAAM,IAAI,uBAAA,IAAI,+BAAK,CAAC,OAAO,CAAC;IAC/C,CAAC;IAED,IAAI,OAAO;QACT,OAAO,uBAAA,IAAI,+BAAK,CAAC,OAAO,CAAC;IAC3B,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACtB,CAAC;IAED,OAAO;QACL,aAAa;QACb,uBAAA,IAAI,2BAAQ,IAAI,MAAA,CAAC;QACjB,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;CACF","sourcesContent":["import \"@koa/router\";\nimport {IncomingEvent, PlatformContext, PlatformRequest} from \"@tsed/common\";\nimport {IncomingMessage} from \"http\";\nimport Koa from \"koa\";\n\ndeclare module \"koa\" {\n export interface Request {\n id: string;\n $ctx: PlatformContext;\n }\n}\n\ndeclare global {\n namespace TsED {\n export interface Request extends Koa.Request {}\n }\n}\n\n/**\n * @platform\n * @koa\n */\nexport class PlatformKoaRequest extends PlatformRequest<Koa.Request> {\n #ctx: Koa.Context;\n\n constructor(event: IncomingEvent, $ctx: PlatformContext) {\n super(event, $ctx);\n this.#ctx = this.raw.ctx;\n }\n\n get protocol(): string {\n return this.#ctx.request.protocol;\n }\n\n get host(): string {\n return this.#ctx.request.host;\n }\n\n get secure(): boolean {\n return this.#ctx.request.secure;\n }\n\n get cookies(): {[p: string]: any} {\n return this.#ctx.cookie || this.#ctx.cookies;\n }\n\n get session(): any {\n return this.#ctx.session;\n }\n\n getReq(): IncomingMessage {\n return this.raw.req;\n }\n\n destroy() {\n // @ts-ignore\n this.#ctx = null;\n return super.destroy();\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformKoaRequest.js","sourceRoot":"","sources":["../../../src/services/PlatformKoaRequest.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AACrB,OAAO,EAAiC,eAAe,EAAC,MAAM,cAAc,CAAC;AAiB7E;;;GAGG;AACH,MAAM,OAAO,kBAAmB,SAAQ,eAA4B;IAClE,IAAI,CAAc;IAElB,YAAY,KAAoB,EAAE,IAAqB;QACrD,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAC3B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IACpC,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAChC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAClC,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IAC/C,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IAC3B,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACtB,CAAC;IAED,OAAO;QACL,aAAa;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;CACF","sourcesContent":["import \"@koa/router\";\nimport {IncomingEvent, PlatformContext, PlatformRequest} from \"@tsed/common\";\nimport {IncomingMessage} from \"http\";\nimport Koa from \"koa\";\n\ndeclare module \"koa\" {\n export interface Request {\n id: string;\n $ctx: PlatformContext;\n }\n}\n\ndeclare global {\n namespace TsED {\n export interface Request extends Koa.Request {}\n }\n}\n\n/**\n * @platform\n * @koa\n */\nexport class PlatformKoaRequest extends PlatformRequest<Koa.Request> {\n #ctx: Koa.Context;\n\n constructor(event: IncomingEvent, $ctx: PlatformContext) {\n super(event, $ctx);\n this.#ctx = this.raw.ctx;\n }\n\n get protocol(): string {\n return this.#ctx.request.protocol;\n }\n\n get host(): string {\n return this.#ctx.request.host;\n }\n\n get secure(): boolean {\n return this.#ctx.request.secure;\n }\n\n get cookies(): {[p: string]: any} {\n return this.#ctx.cookie || this.#ctx.cookies;\n }\n\n get session(): any {\n return this.#ctx.session;\n }\n\n getReq(): IncomingMessage {\n return this.raw.req;\n }\n\n destroy() {\n // @ts-ignore\n this.#ctx = null;\n return super.destroy();\n }\n}\n"]}
@@ -1,5 +1,3 @@
1
- var _PlatformKoaResponse_ctx;
2
- import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
1
  import { PlatformResponse } from "@tsed/common";
4
2
  import { getStatusMessage } from "@tsed/schema";
5
3
  import encodeUrl from "encodeurl";
@@ -8,16 +6,16 @@ import encodeUrl from "encodeurl";
8
6
  * @koa
9
7
  */
10
8
  export class PlatformKoaResponse extends PlatformResponse {
9
+ #ctx;
11
10
  constructor(event, $ctx) {
12
11
  super(event, $ctx);
13
- _PlatformKoaResponse_ctx.set(this, void 0);
14
- __classPrivateFieldSet(this, _PlatformKoaResponse_ctx, this.raw.ctx, "f");
12
+ this.#ctx = this.raw.ctx;
15
13
  }
16
14
  get statusCode() {
17
15
  return this.raw.status;
18
16
  }
19
17
  get locals() {
20
- return __classPrivateFieldGet(this, _PlatformKoaResponse_ctx, "f").state;
18
+ return this.#ctx.state;
21
19
  }
22
20
  /**
23
21
  * Return the Node.js response object
@@ -97,5 +95,4 @@ export class PlatformKoaResponse extends PlatformResponse {
97
95
  return this;
98
96
  }
99
97
  }
100
- _PlatformKoaResponse_ctx = new WeakMap();
101
98
  //# sourceMappingURL=PlatformKoaResponse.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformKoaResponse.js","sourceRoot":"","sources":["../../../src/services/PlatformKoaResponse.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAiC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAG9E,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,SAAS,MAAM,WAAW,CAAC;AAQlC;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,gBAA8B;IAGrE,YAAY,KAAoB,EAAE,IAAqB;QACrD,KAAK,CAAC,KAA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,MAAM,CAAC,oBAAoB,GAAG,EAAE,CAAC,CAAC;QAChE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACpB,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,IAAW,CAAC,CAAC,CAAC;QAE1E,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE;YAClC,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC;SACrB;aAAM;YACL,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;SACnC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ,CAAC,QAAgB;QACvB,sCAAsC;QACtC,IAAI,QAAQ,KAAK,MAAM,EAAE;YACvB,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC;SAChD;QAED,eAAe;QACf,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;QAE9C,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import {IncomingEvent, PlatformContext, PlatformResponse} from \"@tsed/common\";\nimport {ServerResponse} from \"http\";\nimport Koa from \"koa\";\nimport {getStatusMessage} from \"@tsed/schema\";\nimport encodeUrl from \"encodeurl\";\n\ndeclare global {\n namespace TsED {\n export interface Response extends Koa.Response {}\n }\n}\n\n/**\n * @platform\n * @koa\n */\nexport class PlatformKoaResponse extends PlatformResponse<Koa.Response> {\n #ctx: Koa.Context;\n\n constructor(event: IncomingEvent, $ctx: PlatformContext) {\n super(event, $ctx);\n this.#ctx = this.raw.ctx;\n }\n\n get statusCode() {\n return this.raw.status;\n }\n\n get locals() {\n return this.#ctx.state;\n }\n\n /**\n * Return the Node.js response object\n */\n getRes(): ServerResponse {\n return this.raw.res;\n }\n\n hasStatus() {\n // KOA set 404 by default\n return this.statusCode !== 404;\n }\n\n /**\n * Sets the HTTP status for the response.\n *\n * @param status\n */\n status(status: number) {\n this.raw.status = status;\n\n return this;\n }\n\n /**\n * Set `Content-Type` response header with `type` through `mime.lookup()`\n * when it does not contain \"/\", or set the Content-Type to `type` otherwise.\n *\n * Examples:\n *\n * res.type('.html');\n * res.type('html');\n * res.type('json');\n * res.type('application/json');\n * res.type('png');\n */\n contentType(contentType: string) {\n this.raw.type = contentType;\n\n return this;\n }\n\n getHeaders() {\n return this.raw.headers;\n }\n\n /**\n * Send any data to your consumer.\n *\n * This method accept a ReadableStream, a plain object, boolean, string, number, null and undefined data.\n * It choose the better way to send the data.\n *\n * @param data\n */\n body(data: any): this {\n this.raw.body = data;\n\n return this;\n }\n\n getBody(): any {\n return this.raw.body;\n }\n\n redirect(status: number, url: string): this {\n status = status || 302;\n // Set location header\n url = this.location(url).raw.get(\"Location\");\n\n this.body(`${getStatusMessage(status)}. Redirecting to ${url}`);\n this.status(status);\n this.setHeader(\"Content-Length\", Buffer.byteLength(this.raw.body as any));\n\n if (this.request.method === \"HEAD\") {\n this.getRes().end();\n } else {\n this.getRes().end(this.getBody());\n }\n\n return this;\n }\n\n location(location: string): this {\n // \"back\" is an alias for the referrer\n if (location === \"back\") {\n location = this.request.get(\"Referrer\") || \"/\";\n }\n\n // set location\n this.raw.set(\"Location\", encodeUrl(location));\n\n return this;\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformKoaResponse.js","sourceRoot":"","sources":["../../../src/services/PlatformKoaResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAG9E,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,SAAS,MAAM,WAAW,CAAC;AAQlC;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,gBAA8B;IACrE,IAAI,CAAc;IAElB,YAAY,KAAoB,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BAAgB,CAAC,MAAM,CAAC,oBAAoB,GAAG,EAAE,CAAC,CAAC;QAChE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACpB,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,IAAW,CAAC,CAAC,CAAC;QAE1E,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE;YAClC,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC;SACrB;aAAM;YACL,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;SACnC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ,CAAC,QAAgB;QACvB,sCAAsC;QACtC,IAAI,QAAQ,KAAK,MAAM,EAAE;YACvB,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC;SAChD;QAED,eAAe;QACf,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;QAE9C,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import {IncomingEvent, PlatformContext, PlatformResponse} from \"@tsed/common\";\nimport {ServerResponse} from \"http\";\nimport Koa from \"koa\";\nimport {getStatusMessage} from \"@tsed/schema\";\nimport encodeUrl from \"encodeurl\";\n\ndeclare global {\n namespace TsED {\n export interface Response extends Koa.Response {}\n }\n}\n\n/**\n * @platform\n * @koa\n */\nexport class PlatformKoaResponse extends PlatformResponse<Koa.Response> {\n #ctx: Koa.Context;\n\n constructor(event: IncomingEvent, $ctx: PlatformContext) {\n super(event, $ctx);\n this.#ctx = this.raw.ctx;\n }\n\n get statusCode() {\n return this.raw.status;\n }\n\n get locals() {\n return this.#ctx.state;\n }\n\n /**\n * Return the Node.js response object\n */\n getRes(): ServerResponse {\n return this.raw.res;\n }\n\n hasStatus() {\n // KOA set 404 by default\n return this.statusCode !== 404;\n }\n\n /**\n * Sets the HTTP status for the response.\n *\n * @param status\n */\n status(status: number) {\n this.raw.status = status;\n\n return this;\n }\n\n /**\n * Set `Content-Type` response header with `type` through `mime.lookup()`\n * when it does not contain \"/\", or set the Content-Type to `type` otherwise.\n *\n * Examples:\n *\n * res.type('.html');\n * res.type('html');\n * res.type('json');\n * res.type('application/json');\n * res.type('png');\n */\n contentType(contentType: string) {\n this.raw.type = contentType;\n\n return this;\n }\n\n getHeaders() {\n return this.raw.headers;\n }\n\n /**\n * Send any data to your consumer.\n *\n * This method accept a ReadableStream, a plain object, boolean, string, number, null and undefined data.\n * It choose the better way to send the data.\n *\n * @param data\n */\n body(data: any): this {\n this.raw.body = data;\n\n return this;\n }\n\n getBody(): any {\n return this.raw.body;\n }\n\n redirect(status: number, url: string): this {\n status = status || 302;\n // Set location header\n url = this.location(url).raw.get(\"Location\");\n\n this.body(`${getStatusMessage(status)}. Redirecting to ${url}`);\n this.status(status);\n this.setHeader(\"Content-Length\", Buffer.byteLength(this.raw.body as any));\n\n if (this.request.method === \"HEAD\") {\n this.getRes().end();\n } else {\n this.getRes().end(this.getBody());\n }\n\n return this;\n }\n\n location(location: string): this {\n // \"back\" is an alias for the referrer\n if (location === \"back\") {\n location = this.request.get(\"Referrer\") || \"/\";\n }\n\n // set location\n this.raw.set(\"Location\", encodeUrl(location));\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.114.15",
3
+ "version": "6.114.18",
4
4
  "description": "Koa package for Ts.ED framework",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
@@ -18,7 +18,8 @@
18
18
  "build:cjs": "tsc --build tsconfig.compile.json",
19
19
  "build:esm": "tsc --build tsconfig.compile.esm.json",
20
20
  "barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\"",
21
- "start": "ts-node -r tsconfig-paths/register test/app/index.ts"
21
+ "start": "ts-node -r tsconfig-paths/register test/app/index.ts",
22
+ "test": "cross-env NODE_ENV=test yarn jest --max-workers=2 --testTimeout 10000"
22
23
  },
23
24
  "keywords": [
24
25
  "Koa",
@@ -51,10 +52,10 @@
51
52
  "repository": "https://github.com/tsedio/tsed",
52
53
  "devDependencies": {
53
54
  "@koa/cors": "3.3.0",
54
- "@tsed/common": "6.114.15",
55
- "@tsed/core": "6.114.15",
56
- "@tsed/di": "6.114.15",
57
- "@tsed/platform-test-utils": "6.114.15",
55
+ "@tsed/common": "6.114.18",
56
+ "@tsed/core": "6.114.18",
57
+ "@tsed/di": "6.114.18",
58
+ "@tsed/platform-test-utils": "6.114.18",
58
59
  "@types/koa": "2.13.4",
59
60
  "@types/koa-bodyparser": "4.3.7",
60
61
  "@types/koa-compose": "3.2.5",
@@ -75,23 +76,24 @@
75
76
  "@koa/router": "^10.1.1",
76
77
  "encodeurl": "^1.0.2",
77
78
  "koa-send": "5.0.1",
78
- "multer": "^1.4.4",
79
- "tslib": "2.3.1"
79
+ "multer": "^1.4.5-lts.1",
80
+ "tslib": "2.4.0"
80
81
  },
81
82
  "peerDependencies": {
82
- "@tsed/common": "^6.114.15",
83
- "@tsed/core": "^6.114.15",
84
- "@tsed/di": "^6.114.15",
85
- "@tsed/json-mapper": "^6.114.15",
86
- "@tsed/logger": ">=6.1.1",
87
- "@tsed/openspec": "^6.114.15",
88
- "@tsed/schema": "^6.114.15",
83
+ "@tsed/common": "^6.114.18",
84
+ "@tsed/core": "^6.114.18",
85
+ "@tsed/di": "^6.114.18",
86
+ "@tsed/json-mapper": "^6.114.18",
87
+ "@tsed/logger": ">=6.1.4",
88
+ "@tsed/openspec": "^6.114.18",
89
+ "@tsed/schema": "^6.114.18",
89
90
  "koa": ">=2.13.0",
90
91
  "koa-bodyparser": ">=4.3.0",
91
92
  "koa-compress": ">=5.0.1",
92
93
  "koa-override": ">=3.0.0",
93
94
  "koa-qs": ">=3.0.0",
94
- "koa-session": ">=6.2.0"
95
+ "koa-session": ">=6.2.0",
96
+ "multer": "^1.4.5-lts.1"
95
97
  },
96
98
  "peerDependenciesMeta": {
97
99
  "@tsed/common": {
@@ -114,6 +116,9 @@
114
116
  },
115
117
  "@tsed/logger": {
116
118
  "optional": false
119
+ },
120
+ "multer": {
121
+ "optional": false
117
122
  }
118
123
  }
119
124
  }