@tsed/platform-koa 6.107.3 → 6.108.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.
package/lib/cjs/index.js CHANGED
@@ -4,21 +4,21 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const tslib_1 = require("tslib");
7
- (0, tslib_1.__exportStar)(require("./exports"), exports);
8
- (0, tslib_1.__exportStar)(require("./components/PlatformKoa"), exports);
9
- (0, tslib_1.__exportStar)(require("./decorators/caseSensitive"), exports);
10
- (0, tslib_1.__exportStar)(require("./decorators/ctx"), exports);
11
- (0, tslib_1.__exportStar)(require("./decorators/routerSettings"), exports);
12
- (0, tslib_1.__exportStar)(require("./decorators/state"), exports);
13
- (0, tslib_1.__exportStar)(require("./decorators/strict"), exports);
14
- (0, tslib_1.__exportStar)(require("./interfaces/PlatformKoaSettings"), exports);
15
- (0, tslib_1.__exportStar)(require("./interfaces/interfaces"), exports);
16
- (0, tslib_1.__exportStar)(require("./middlewares/resourceNotFoundMiddleware"), exports);
17
- (0, tslib_1.__exportStar)(require("./middlewares/staticsMiddleware"), exports);
18
- (0, tslib_1.__exportStar)(require("./services/PlatformKoaApplication"), exports);
19
- (0, tslib_1.__exportStar)(require("./services/PlatformKoaHandler"), exports);
20
- (0, tslib_1.__exportStar)(require("./services/PlatformKoaRequest"), exports);
21
- (0, tslib_1.__exportStar)(require("./services/PlatformKoaResponse"), exports);
22
- (0, tslib_1.__exportStar)(require("./services/PlatformKoaRouter"), exports);
23
- (0, tslib_1.__exportStar)(require("./utils/multer"), exports);
7
+ tslib_1.__exportStar(require("./exports"), exports);
8
+ tslib_1.__exportStar(require("./components/PlatformKoa"), exports);
9
+ tslib_1.__exportStar(require("./decorators/caseSensitive"), exports);
10
+ tslib_1.__exportStar(require("./decorators/ctx"), exports);
11
+ tslib_1.__exportStar(require("./decorators/routerSettings"), exports);
12
+ tslib_1.__exportStar(require("./decorators/state"), exports);
13
+ tslib_1.__exportStar(require("./decorators/strict"), exports);
14
+ tslib_1.__exportStar(require("./interfaces/PlatformKoaSettings"), exports);
15
+ tslib_1.__exportStar(require("./interfaces/interfaces"), exports);
16
+ tslib_1.__exportStar(require("./middlewares/resourceNotFoundMiddleware"), exports);
17
+ tslib_1.__exportStar(require("./middlewares/staticsMiddleware"), exports);
18
+ tslib_1.__exportStar(require("./services/PlatformKoaApplication"), exports);
19
+ tslib_1.__exportStar(require("./services/PlatformKoaHandler"), exports);
20
+ tslib_1.__exportStar(require("./services/PlatformKoaRequest"), exports);
21
+ tslib_1.__exportStar(require("./services/PlatformKoaResponse"), exports);
22
+ tslib_1.__exportStar(require("./services/PlatformKoaRouter"), exports);
23
+ tslib_1.__exportStar(require("./utils/multer"), exports);
24
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,yDAA0B;AAC1B,wEAAyC;AACzC,0EAA2C;AAC3C,gEAAiC;AACjC,2EAA4C;AAC5C,kEAAmC;AACnC,mEAAoC;AACpC,gFAAiD;AACjD,uEAAwC;AACxC,wFAAyD;AACzD,+EAAgD;AAChD,iFAAkD;AAClD,6EAA8C;AAC9C,6EAA8C;AAC9C,8EAA+C;AAC/C,4EAA6C;AAC7C,8DAA+B","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./exports\";\nexport * from \"./components/PlatformKoa\";\nexport * from \"./decorators/caseSensitive\";\nexport * from \"./decorators/ctx\";\nexport * from \"./decorators/routerSettings\";\nexport * from \"./decorators/state\";\nexport * from \"./decorators/strict\";\nexport * from \"./interfaces/PlatformKoaSettings\";\nexport * from \"./interfaces/interfaces\";\nexport * from \"./middlewares/resourceNotFoundMiddleware\";\nexport * from \"./middlewares/staticsMiddleware\";\nexport * from \"./services/PlatformKoaApplication\";\nexport * from \"./services/PlatformKoaHandler\";\nexport * from \"./services/PlatformKoaRequest\";\nexport * from \"./services/PlatformKoaResponse\";\nexport * from \"./services/PlatformKoaRouter\";\nexport * from \"./utils/multer\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,oDAA0B;AAC1B,mEAAyC;AACzC,qEAA2C;AAC3C,2DAAiC;AACjC,sEAA4C;AAC5C,6DAAmC;AACnC,8DAAoC;AACpC,2EAAiD;AACjD,kEAAwC;AACxC,mFAAyD;AACzD,0EAAgD;AAChD,4EAAkD;AAClD,wEAA8C;AAC9C,wEAA8C;AAC9C,yEAA+C;AAC/C,uEAA6C;AAC7C,yDAA+B","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./exports\";\nexport * from \"./components/PlatformKoa\";\nexport * from \"./decorators/caseSensitive\";\nexport * from \"./decorators/ctx\";\nexport * from \"./decorators/routerSettings\";\nexport * from \"./decorators/state\";\nexport * from \"./decorators/strict\";\nexport * from \"./interfaces/PlatformKoaSettings\";\nexport * from \"./interfaces/interfaces\";\nexport * from \"./middlewares/resourceNotFoundMiddleware\";\nexport * from \"./middlewares/staticsMiddleware\";\nexport * from \"./services/PlatformKoaApplication\";\nexport * from \"./services/PlatformKoaHandler\";\nexport * from \"./services/PlatformKoaRequest\";\nexport * from \"./services/PlatformKoaResponse\";\nexport * from \"./services/PlatformKoaRouter\";\nexport * from \"./utils/multer\";\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- (0, tslib_1.__exportStar)(require("./PlatformKoaSettings"), exports);
4
+ tslib_1.__exportStar(require("./PlatformKoaSettings"), exports);
5
5
  //# sourceMappingURL=interfaces.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":";;;AAGA,qEAAsC","sourcesContent":["import Koa from \"koa\";\nimport {PlatformKoaSettings} from \"./PlatformKoaSettings\";\n\nexport * from \"./PlatformKoaSettings\";\n\ndeclare global {\n namespace TsED {\n export interface Configuration {\n /**\n * Configuration related to Koa platform application.\n */\n koa: PlatformKoaSettings;\n }\n\n export interface NextFunction extends Koa.Next {}\n }\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":";;;AAGA,gEAAsC","sourcesContent":["import Koa from \"koa\";\nimport {PlatformKoaSettings} from \"./PlatformKoaSettings\";\n\nexport * from \"./PlatformKoaSettings\";\n\ndeclare global {\n namespace TsED {\n export interface Configuration {\n /**\n * Configuration related to Koa platform application.\n */\n koa: PlatformKoaSettings;\n }\n\n export interface NextFunction extends Koa.Next {}\n }\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.staticsMiddleware = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const koa_send_1 = (0, tslib_1.__importDefault)(require("koa-send"));
5
+ const koa_send_1 = tslib_1.__importDefault(require("koa-send"));
6
6
  /**
7
7
  * @ignore
8
8
  * @param options
@@ -1 +1 @@
1
- {"version":3,"file":"staticsMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/staticsMiddleware.ts"],"names":[],"mappings":";;;;AAEA,qEAA4B;AAE5B;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,OAA+B;IAC/D,IAAI,OAAO,CAAC,KAAK,KAAK,KAAK;QAAE,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,YAAY,CAAC;IAE3E,OAAO,KAAK,EAAE,GAAY,EAAE,IAAS,EAAE,EAAE;QACvC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;YACrD,IAAI,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;YAEpB,IAAI,GAAG,CAAC,aAAa,IAAI,GAAG,CAAC,aAAa,KAAK,GAAG,EAAE;gBAClD,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;aACzE;YACD,IAAI;gBACF,MAAM,IAAI,GAAG,MAAM,IAAA,kBAAI,EAAC,GAAU,EAAE,IAAI,EAAE,OAA2B,CAAC,CAAC;gBAEvE,IAAI,IAAI,EAAE;oBACR,OAAO;iBACR;aACF;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE;oBACtB,MAAM,GAAG,CAAC;iBACX;aACF;SACF;QAED,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAzBD,8CAyBC","sourcesContent":["import {PlatformStaticsOptions} from \"@tsed/common\";\nimport type {Context} from \"koa\";\nimport send from \"koa-send\";\n\n/**\n * @ignore\n * @param options\n */\nexport function staticsMiddleware(options: PlatformStaticsOptions): any {\n if (options.index !== false) options.index = options.index || \"index.html\";\n\n return async (ctx: Context, next: any) => {\n if ([\"GET\", \"HEAD\"].includes(ctx.method) && !ctx.body) {\n let path = ctx.path;\n\n if (ctx._matchedRoute && ctx._matchedRoute !== \"/\") {\n path = path.replace(String(ctx._matchedRoute).replace(\"/(.*)\", \"\"), \"\");\n }\n try {\n const done = await send(ctx as any, path, options as send.SendOptions);\n\n if (done) {\n return;\n }\n } catch (err) {\n if (err.status !== 404) {\n throw err;\n }\n }\n }\n\n return next();\n };\n}\n"]}
1
+ {"version":3,"file":"staticsMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/staticsMiddleware.ts"],"names":[],"mappings":";;;;AAEA,gEAA4B;AAE5B;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,OAA+B;IAC/D,IAAI,OAAO,CAAC,KAAK,KAAK,KAAK;QAAE,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,YAAY,CAAC;IAE3E,OAAO,KAAK,EAAE,GAAY,EAAE,IAAS,EAAE,EAAE;QACvC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;YACrD,IAAI,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;YAEpB,IAAI,GAAG,CAAC,aAAa,IAAI,GAAG,CAAC,aAAa,KAAK,GAAG,EAAE;gBAClD,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;aACzE;YACD,IAAI;gBACF,MAAM,IAAI,GAAG,MAAM,IAAA,kBAAI,EAAC,GAAU,EAAE,IAAI,EAAE,OAA2B,CAAC,CAAC;gBAEvE,IAAI,IAAI,EAAE;oBACR,OAAO;iBACR;aACF;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE;oBACtB,MAAM,GAAG,CAAC;iBACX;aACF;SACF;QAED,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAzBD,8CAyBC","sourcesContent":["import {PlatformStaticsOptions} from \"@tsed/common\";\nimport type {Context} from \"koa\";\nimport send from \"koa-send\";\n\n/**\n * @ignore\n * @param options\n */\nexport function staticsMiddleware(options: PlatformStaticsOptions): any {\n if (options.index !== false) options.index = options.index || \"index.html\";\n\n return async (ctx: Context, next: any) => {\n if ([\"GET\", \"HEAD\"].includes(ctx.method) && !ctx.body) {\n let path = ctx.path;\n\n if (ctx._matchedRoute && ctx._matchedRoute !== \"/\") {\n path = path.replace(String(ctx._matchedRoute).replace(\"/(.*)\", \"\"), \"\");\n }\n try {\n const done = await send(ctx as any, path, options as send.SendOptions);\n\n if (done) {\n return;\n }\n } catch (err) {\n if (err.status !== 404) {\n throw err;\n }\n }\n }\n\n return next();\n };\n}\n"]}
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PlatformKoaApplication = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const common_1 = require("@tsed/common");
6
- const koa_1 = (0, tslib_1.__importDefault)(require("koa"));
6
+ const koa_1 = tslib_1.__importDefault(require("koa"));
7
7
  const PlatformKoaRouter_1 = require("./PlatformKoaRouter");
8
8
  const koaQs = require("koa-qs");
9
9
  /**
@@ -23,10 +23,10 @@ let PlatformKoaApplication = class PlatformKoaApplication extends PlatformKoaRou
23
23
  return this.getApp().callback();
24
24
  }
25
25
  };
26
- PlatformKoaApplication = (0, tslib_1.__decorate)([
27
- (0, tslib_1.__param)(0, (0, common_1.Inject)()),
28
- (0, tslib_1.__param)(1, (0, common_1.Configuration)()),
29
- (0, tslib_1.__metadata)("design:paramtypes", [common_1.PlatformHandler, Object])
26
+ PlatformKoaApplication = tslib_1.__decorate([
27
+ tslib_1.__param(0, (0, common_1.Inject)()),
28
+ tslib_1.__param(1, (0, common_1.Configuration)()),
29
+ tslib_1.__metadata("design:paramtypes", [common_1.PlatformHandler, Object])
30
30
  ], PlatformKoaApplication);
31
31
  exports.PlatformKoaApplication = PlatformKoaApplication;
32
32
  //# sourceMappingURL=PlatformKoaApplication.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformKoaApplication.js","sourceRoot":"","sources":["../../../src/services/PlatformKoaApplication.ts"],"names":[],"mappings":";;;;AACA,yCAAyF;AACzF,2DAAsB;AACtB,2DAAsD;AAEtD,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAQhC;;;GAGG;AACH,IAAa,sBAAsB,GAAnC,MAAa,sBAAuB,SAAQ,qCAAiB;IAI3D,YAAsB,eAAgC,EAAmB,aAA4B;QACnG,KAAK,CAAC,eAAe,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC;QAE1C,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,IAAI,aAAG,EAAE,CAAC;QACxD,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACjC,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;IAClC,CAAC;CACF,CAAA;AAlBY,sBAAsB;IAIpB,wBAAA,IAAA,eAAM,GAAE,CAAA;IAAoC,wBAAA,IAAA,sBAAa,GAAE,CAAA;kDAAjC,wBAAe;GAJ3C,sBAAsB,CAkBlC;AAlBY,wDAAsB","sourcesContent":["import KoaRouter from \"@koa/router\";\nimport {Configuration, Inject, PlatformApplication, PlatformHandler} from \"@tsed/common\";\nimport Koa from \"koa\";\nimport {PlatformKoaRouter} from \"./PlatformKoaRouter\";\n\nconst koaQs = require(\"koa-qs\");\n\ndeclare global {\n namespace TsED {\n export interface Application extends Koa {}\n }\n}\n\n/**\n * @platform\n * @express\n */\nexport class PlatformKoaApplication extends PlatformKoaRouter implements PlatformApplication<Koa, KoaRouter> {\n app: Koa;\n rawApp: Koa;\n\n constructor(@Inject() platformHandler: PlatformHandler, @Configuration() configuration: Configuration) {\n super(platformHandler, configuration, {});\n\n this.rawApp = configuration.get(\"koa.app\") || new Koa();\n koaQs(this.rawApp, \"extended\");\n }\n\n getApp(): Koa {\n return this.rawApp;\n }\n\n callback(): any {\n return this.getApp().callback();\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformKoaApplication.js","sourceRoot":"","sources":["../../../src/services/PlatformKoaApplication.ts"],"names":[],"mappings":";;;;AACA,yCAAyF;AACzF,sDAAsB;AACtB,2DAAsD;AAEtD,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAQhC;;;GAGG;AACH,IAAa,sBAAsB,GAAnC,MAAa,sBAAuB,SAAQ,qCAAiB;IAI3D,YAAsB,eAAgC,EAAmB,aAA4B;QACnG,KAAK,CAAC,eAAe,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC;QAE1C,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,IAAI,aAAG,EAAE,CAAC;QACxD,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACjC,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;IAClC,CAAC;CACF,CAAA;AAlBY,sBAAsB;IAIpB,mBAAA,IAAA,eAAM,GAAE,CAAA;IAAoC,mBAAA,IAAA,sBAAa,GAAE,CAAA;6CAAjC,wBAAe;GAJ3C,sBAAsB,CAkBlC;AAlBY,wDAAsB","sourcesContent":["import KoaRouter from \"@koa/router\";\nimport {Configuration, Inject, PlatformApplication, PlatformHandler} from \"@tsed/common\";\nimport Koa from \"koa\";\nimport {PlatformKoaRouter} from \"./PlatformKoaRouter\";\n\nconst koaQs = require(\"koa-qs\");\n\ndeclare global {\n namespace TsED {\n export interface Application extends Koa {}\n }\n}\n\n/**\n * @platform\n * @express\n */\nexport class PlatformKoaApplication extends PlatformKoaRouter implements PlatformApplication<Koa, KoaRouter> {\n app: Koa;\n rawApp: Koa;\n\n constructor(@Inject() platformHandler: PlatformHandler, @Configuration() configuration: Configuration) {\n super(platformHandler, configuration, {});\n\n this.rawApp = configuration.get(\"koa.app\") || new Koa();\n koaQs(this.rawApp, \"extended\");\n }\n\n getApp(): Koa {\n return this.rawApp;\n }\n\n callback(): any {\n return this.getApp().callback();\n }\n}\n"]}
@@ -13,29 +13,29 @@ class PlatformKoaRequest extends common_1.PlatformRequest {
13
13
  constructor(event, $ctx) {
14
14
  super(event, $ctx);
15
15
  _PlatformKoaRequest_ctx.set(this, void 0);
16
- (0, tslib_1.__classPrivateFieldSet)(this, _PlatformKoaRequest_ctx, this.raw.ctx, "f");
16
+ tslib_1.__classPrivateFieldSet(this, _PlatformKoaRequest_ctx, this.raw.ctx, "f");
17
17
  }
18
18
  get protocol() {
19
- return (0, tslib_1.__classPrivateFieldGet)(this, _PlatformKoaRequest_ctx, "f").request.protocol;
19
+ return tslib_1.__classPrivateFieldGet(this, _PlatformKoaRequest_ctx, "f").request.protocol;
20
20
  }
21
21
  get host() {
22
- return (0, tslib_1.__classPrivateFieldGet)(this, _PlatformKoaRequest_ctx, "f").request.host;
22
+ return tslib_1.__classPrivateFieldGet(this, _PlatformKoaRequest_ctx, "f").request.host;
23
23
  }
24
24
  get secure() {
25
- return (0, tslib_1.__classPrivateFieldGet)(this, _PlatformKoaRequest_ctx, "f").request.secure;
25
+ return tslib_1.__classPrivateFieldGet(this, _PlatformKoaRequest_ctx, "f").request.secure;
26
26
  }
27
27
  get cookies() {
28
- return (0, tslib_1.__classPrivateFieldGet)(this, _PlatformKoaRequest_ctx, "f").cookie || (0, tslib_1.__classPrivateFieldGet)(this, _PlatformKoaRequest_ctx, "f").cookies;
28
+ return tslib_1.__classPrivateFieldGet(this, _PlatformKoaRequest_ctx, "f").cookie || tslib_1.__classPrivateFieldGet(this, _PlatformKoaRequest_ctx, "f").cookies;
29
29
  }
30
30
  get session() {
31
- return (0, tslib_1.__classPrivateFieldGet)(this, _PlatformKoaRequest_ctx, "f").session;
31
+ return tslib_1.__classPrivateFieldGet(this, _PlatformKoaRequest_ctx, "f").session;
32
32
  }
33
33
  getReq() {
34
34
  return this.raw.req;
35
35
  }
36
36
  destroy() {
37
37
  // @ts-ignore
38
- (0, tslib_1.__classPrivateFieldSet)(this, _PlatformKoaRequest_ctx, null, "f");
38
+ tslib_1.__classPrivateFieldSet(this, _PlatformKoaRequest_ctx, null, "f");
39
39
  return super.destroy();
40
40
  }
41
41
  }
@@ -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,oCAAA,IAAI,2BAAQ,IAAI,CAAC,GAAG,CAAC,GAAG,MAAA,CAAC;IAC3B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,oCAAA,IAAI,+BAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;IACpC,CAAC;IAED,IAAI,IAAI;QACN,OAAO,oCAAA,IAAI,+BAAK,CAAC,OAAO,CAAC,IAAI,CAAC;IAChC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,oCAAA,IAAI,+BAAK,CAAC,OAAO,CAAC,MAAM,CAAC;IAClC,CAAC;IAED,IAAI,OAAO;QACT,OAAO,oCAAA,IAAI,+BAAK,CAAC,MAAM,IAAI,oCAAA,IAAI,+BAAK,CAAC,OAAO,CAAC;IAC/C,CAAC;IAED,IAAI,OAAO;QACT,OAAO,oCAAA,IAAI,+BAAK,CAAC,OAAO,CAAC;IAC3B,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACtB,CAAC;IAED,OAAO;QACL,aAAa;QACb,oCAAA,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;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"]}
@@ -5,7 +5,7 @@ exports.PlatformKoaResponse = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  const common_1 = require("@tsed/common");
7
7
  const schema_1 = require("@tsed/schema");
8
- const encodeurl_1 = (0, tslib_1.__importDefault)(require("encodeurl"));
8
+ const encodeurl_1 = tslib_1.__importDefault(require("encodeurl"));
9
9
  /**
10
10
  * @platform
11
11
  * @koa
@@ -14,13 +14,13 @@ class PlatformKoaResponse extends common_1.PlatformResponse {
14
14
  constructor(event, $ctx) {
15
15
  super(event, $ctx);
16
16
  _PlatformKoaResponse_ctx.set(this, void 0);
17
- (0, tslib_1.__classPrivateFieldSet)(this, _PlatformKoaResponse_ctx, this.raw.ctx, "f");
17
+ tslib_1.__classPrivateFieldSet(this, _PlatformKoaResponse_ctx, this.raw.ctx, "f");
18
18
  }
19
19
  get statusCode() {
20
20
  return this.raw.status;
21
21
  }
22
22
  get locals() {
23
- return (0, tslib_1.__classPrivateFieldGet)(this, _PlatformKoaResponse_ctx, "f").state;
23
+ return tslib_1.__classPrivateFieldGet(this, _PlatformKoaResponse_ctx, "f").state;
24
24
  }
25
25
  /**
26
26
  * Return the Node.js response object
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformKoaResponse.js","sourceRoot":"","sources":["../../../src/services/PlatformKoaResponse.ts"],"names":[],"mappings":";;;;;AAAA,yCAA8E;AAG9E,yCAA8C;AAC9C,uEAAkC;AAQlC;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,yBAA8B;IAGrE,YAAY,KAAoB,EAAE,IAAqB;QACrD,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAHrB,2CAAkB;QAIhB,oCAAA,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,oCAAA,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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AAM,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,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() {\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));\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;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;;;;;;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GAAG,CAAC,UAAU,CAAC,IAAI,GAAG,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"]}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PlatformKoaRouter = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const router_1 = (0, tslib_1.__importDefault)(require("@koa/router"));
5
+ const router_1 = tslib_1.__importDefault(require("@koa/router"));
6
6
  const common_1 = require("@tsed/common");
7
7
  const di_1 = require("@tsed/di");
8
8
  const staticsMiddleware_1 = require("../middlewares/staticsMiddleware");
@@ -36,10 +36,10 @@ let PlatformKoaRouter = class PlatformKoaRouter extends common_1.PlatformRouter
36
36
  return this;
37
37
  }
38
38
  };
39
- PlatformKoaRouter = (0, tslib_1.__decorate)([
40
- (0, tslib_1.__param)(1, (0, di_1.Configuration)()),
41
- (0, tslib_1.__param)(2, (0, di_1.Inject)(common_1.PLATFORM_ROUTER_OPTIONS)),
42
- (0, tslib_1.__metadata)("design:paramtypes", [common_1.PlatformHandler, Object, Object])
39
+ PlatformKoaRouter = tslib_1.__decorate([
40
+ tslib_1.__param(1, (0, di_1.Configuration)()),
41
+ tslib_1.__param(2, (0, di_1.Inject)(common_1.PLATFORM_ROUTER_OPTIONS)),
42
+ tslib_1.__metadata("design:paramtypes", [common_1.PlatformHandler, Object, Object])
43
43
  ], PlatformKoaRouter);
44
44
  exports.PlatformKoaRouter = PlatformKoaRouter;
45
45
  //# sourceMappingURL=PlatformKoaRouter.js.map
@@ -1 +1 @@
1
- {"version":3,"file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EAAE,IAAA,qCAAiB,EAAC,OAAO,CAAQ,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAzBY,iBAAiB;IAGzB,wBAAA,IAAA,kBAAa,GAAE,CAAA;IACf,wBAAA,IAAA,WAAM,EAAC,gCAAuB,CAAC,CAAA;kDAFtB,wBAAe;GAFhB,iBAAiB,CAyB7B;AAzBY,8CAAiB","sourcesContent":["import KoaRouter from \"@koa/router\";\nimport {RouterOptions as KoaRouterOptions} from \"@koa/router\";\n\nimport {\n PLATFORM_ROUTER_OPTIONS,\n PlatformHandler,\n PlatformMulter,\n PlatformMulterSettings,\n PlatformRouter,\n PlatformStaticsOptions\n} from \"@tsed/common\";\nimport {Configuration, Inject} from \"@tsed/di\";\nimport send from \"koa-send\";\nimport {staticsMiddleware} from \"../middlewares/staticsMiddleware\";\nimport {getMulter} from \"../utils/multer\";\n\ndeclare global {\n namespace TsED {\n export interface Router extends KoaRouter {}\n\n export interface RouterOptions extends KoaRouterOptions {}\n\n export interface StaticsOptions extends send.SendOptions {}\n }\n}\n\n// @ts-ignore\nKoaRouter.prototype.$$match = KoaRouter.prototype.match;\nKoaRouter.prototype.match = function match(...args: any[]) {\n const matched = this.$$match(...args);\n if (matched) {\n if (matched.path.length) {\n matched.route = true;\n }\n }\n\n return matched;\n};\n\nexport class PlatformKoaRouter extends PlatformRouter<KoaRouter> {\n constructor(\n platform: PlatformHandler,\n @Configuration() configuration: Configuration,\n @Inject(PLATFORM_ROUTER_OPTIONS) routerOptions: any\n ) {\n super(platform);\n\n const options = Object.assign({}, configuration.koa?.router || {}, routerOptions);\n this.rawRouter = new KoaRouter(options) as any;\n }\n\n callback() {\n return [this.getRouter().routes(), this.getRouter().allowedMethods()];\n }\n\n multer(options: PlatformMulterSettings): PlatformMulter {\n return getMulter(options);\n }\n\n statics(path: string, options: PlatformStaticsOptions) {\n this.rawRouter.use(path, staticsMiddleware(options) as any);\n\n return this;\n }\n}\n"]}
1
+ {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C,IAAI,EAAE,IAAA,qCAAiB,EAAC,OAAO,CAAQ,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAzBY,iBAAiB;IAGzB,mBAAA,IAAA,kBAAa,GAAE,CAAA;IACf,mBAAA,IAAA,WAAM,EAAC,gCAAuB,CAAC,CAAA;6CAFtB,wBAAe;GAFhB,iBAAiB,CAyB7B;AAzBY,8CAAiB","sourcesContent":["import KoaRouter from \"@koa/router\";\nimport {RouterOptions as KoaRouterOptions} from \"@koa/router\";\n\nimport {\n PLATFORM_ROUTER_OPTIONS,\n PlatformHandler,\n PlatformMulter,\n PlatformMulterSettings,\n PlatformRouter,\n PlatformStaticsOptions\n} from \"@tsed/common\";\nimport {Configuration, Inject} from \"@tsed/di\";\nimport send from \"koa-send\";\nimport {staticsMiddleware} from \"../middlewares/staticsMiddleware\";\nimport {getMulter} from \"../utils/multer\";\n\ndeclare global {\n namespace TsED {\n export interface Router extends KoaRouter {}\n\n export interface RouterOptions extends KoaRouterOptions {}\n\n export interface StaticsOptions extends send.SendOptions {}\n }\n}\n\n// @ts-ignore\nKoaRouter.prototype.$$match = KoaRouter.prototype.match;\nKoaRouter.prototype.match = function match(...args: any[]) {\n const matched = this.$$match(...args);\n if (matched) {\n if (matched.path.length) {\n matched.route = true;\n }\n }\n\n return matched;\n};\n\nexport class PlatformKoaRouter extends PlatformRouter<KoaRouter> {\n constructor(\n platform: PlatformHandler,\n @Configuration() configuration: Configuration,\n @Inject(PLATFORM_ROUTER_OPTIONS) routerOptions: any\n ) {\n super(platform);\n\n const options = Object.assign({}, configuration.koa?.router || {}, routerOptions);\n this.rawRouter = new KoaRouter(options) as any;\n }\n\n callback() {\n return [this.getRouter().routes(), this.getRouter().allowedMethods()];\n }\n\n multer(options: PlatformMulterSettings): PlatformMulter {\n return getMulter(options);\n }\n\n statics(path: string, options: PlatformStaticsOptions) {\n this.rawRouter.use(path, staticsMiddleware(options) as any);\n\n return this;\n }\n}\n"]}
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1 +1 @@
1
- {"version":3,"file":"multer.js","sourceRoot":"","sources":["../../../src/utils/multer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,+BAA+B;AAE/B,IAAI,MAAW,CAAC;AAChB,kDAAO,QAAQ,IAAE,IAAI,CAAC,CAAC,EAAC,OAAO,EAAE,CAAC,EAAC,EAAE,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;AAEtD;;GAEG;AACH,SAAS,mBAAmB,CAAC,UAAe;IAC1C,OAAO,KAAK,EAAE,OAAoB,EAAE,EAAE;QACpC,MAAM,GAAG,GAAQ,OAAO,CAAC,GAAG,CAAC;QAE7B,MAAM,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;QAEnC,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,EAAE;YACjC,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;gBAChB,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBAChC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACxB,OAAO,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;aACrB;QACH,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(({default: m}) => (multer = m));\n\n/**\n * @ignore\n */\nfunction createRawMiddleware(middleware: any) {\n return async (request: Koa.Request) => {\n const ctx: any = request.ctx;\n\n await middleware(ctx.req, ctx.res);\n\n const forwardKey = (key: string) => {\n if (ctx.req[key]) {\n ctx.request[key] = ctx.req[key];\n ctx[key] = ctx.req[key];\n delete ctx.req[key];\n }\n };\n\n if (\"request\" in ctx) {\n if (ctx.req.body) {\n ctx.request.body = ctx.req.body;\n delete ctx.req.body;\n }\n\n forwardKey(\"file\");\n forwardKey(\"files\");\n }\n };\n}\n\n/**\n * @ignore\n */\nfunction makePromise(multer: any, name: string) {\n // istanbul ignore next\n if (!multer[name]) return;\n\n const fn = multer[name];\n\n multer[name] = function apply(...args: any[]) {\n const middleware = Reflect.apply(fn, this, args);\n\n return createRawMiddleware(promisify(middleware));\n };\n}\n\n/**\n * @ignore\n */\nexport function getMulter(options: any) {\n const m = multer(options);\n\n makePromise(m, \"any\");\n makePromise(m, \"array\");\n makePromise(m, \"fields\");\n makePromise(m, \"none\");\n makePromise(m, \"single\");\n\n return m;\n}\n"]}
1
+ {"version":3,"file":"multer.js","sourceRoot":"","sources":["../../../src/utils/multer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+BAA+B;AAE/B,IAAI,MAAW,CAAC;AAChB,kDAAO,QAAQ,IAAE,IAAI,CAAC,CAAC,EAAC,OAAO,EAAE,CAAC,EAAC,EAAE,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;AAEtD;;GAEG;AACH,SAAS,mBAAmB,CAAC,UAAe;IAC1C,OAAO,KAAK,EAAE,OAAoB,EAAE,EAAE;QACpC,MAAM,GAAG,GAAQ,OAAO,CAAC,GAAG,CAAC;QAE7B,MAAM,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;QAEnC,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,EAAE;YACjC,IAAI,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O,CAAC,CAAC;IACxB,WAAW,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IACzB,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACvB,WAAW,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IAEzB,OAAO,CAAC,CAAC;AACX,CAAC;AAVD,8BAUC","sourcesContent":["import Koa from \"koa\";\nimport {promisify} from \"util\";\n\nlet multer: any;\nimport(\"multer\").then(({default: m}) => (multer = m));\n\n/**\n * @ignore\n */\nfunction createRawMiddleware(middleware: any) {\n return async (request: Koa.Request) => {\n const ctx: any = request.ctx;\n\n await middleware(ctx.req, ctx.res);\n\n const forwardKey = (key: string) => {\n if (ctx.req[key]) {\n ctx.request[key] = ctx.req[key];\n ctx[key] = ctx.req[key];\n delete ctx.req[key];\n }\n };\n\n if (\"request\" in ctx) {\n if (ctx.req.body) {\n ctx.request.body = ctx.req.body;\n delete ctx.req.body;\n }\n\n forwardKey(\"file\");\n forwardKey(\"files\");\n }\n };\n}\n\n/**\n * @ignore\n */\nfunction makePromise(multer: any, name: string) {\n // istanbul ignore next\n if (!multer[name]) return;\n\n const fn = multer[name];\n\n multer[name] = function apply(...args: any[]) {\n const middleware = Reflect.apply(fn, this, args);\n\n return createRawMiddleware(promisify(middleware));\n };\n}\n\n/**\n * @ignore\n */\nexport function getMulter(options: any) {\n const m = multer(options);\n\n makePromise(m, \"any\");\n makePromise(m, \"array\");\n makePromise(m, \"fields\");\n makePromise(m, \"none\");\n makePromise(m, \"single\");\n\n return m;\n}\n"]}
@@ -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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GAAG,CAAC,UAAU,CAAC,CAAC;QAE7C,IAAI,CAAC,IAAI,CAAC,GAAG,gBAAgB,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,IAAI,CAAC,CAAC,CAAC;QAEnE,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() {\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));\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;A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C,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAE7C,IAAI,CAAC,IAAI,CAAC,GAAG,gBAAgB,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"]}
@@ -36,13 +36,13 @@ export declare class PlatformKoa implements PlatformAdapter<Koa, KoaRouter> {
36
36
  * @param module
37
37
  * @param settings
38
38
  */
39
- static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<Koa<Koa.DefaultState, Koa.DefaultContext>, KoaRouter<any, {}>>;
39
+ static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<Koa<Koa.DefaultState, Koa.DefaultContext>, KoaRouter<Koa.DefaultState, Koa.DefaultContext>>;
40
40
  /**
41
41
  * Bootstrap a server application
42
42
  * @param module
43
43
  * @param settings
44
44
  */
45
- static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<Koa<Koa.DefaultState, Koa.DefaultContext>, KoaRouter<any, {}>>>;
45
+ static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<Koa<Koa.DefaultState, Koa.DefaultContext>, KoaRouter<Koa.DefaultState, Koa.DefaultContext>>>;
46
46
  onInit(): void;
47
47
  useRouter(): this;
48
48
  useContext(): this;
@@ -41,7 +41,7 @@ export declare class PlatformKoaResponse extends PlatformResponse<Koa.Response>
41
41
  * res.type('png');
42
42
  */
43
43
  contentType(contentType: string): this;
44
- getHeaders(): any;
44
+ getHeaders(): import("http").OutgoingHttpHeaders;
45
45
  /**
46
46
  * Send any data to your consumer.
47
47
  *
@@ -1,4 +1,5 @@
1
1
  /// <reference types="koa__router" />
2
+ /// <reference types="koa" />
2
3
  import KoaRouter from "@koa/router";
3
4
  import { RouterOptions as KoaRouterOptions } from "@koa/router";
4
5
  import { PlatformHandler, PlatformMulter, PlatformMulterSettings, PlatformRouter, PlatformStaticsOptions } from "@tsed/common";
@@ -16,7 +17,7 @@ declare global {
16
17
  }
17
18
  export declare class PlatformKoaRouter extends PlatformRouter<KoaRouter> {
18
19
  constructor(platform: PlatformHandler, configuration: Configuration, routerOptions: any);
19
- callback(): KoaRouter.Middleware<any, {}>[];
20
+ callback(): KoaRouter.Middleware<import("koa").DefaultState, import("koa").DefaultContext>[];
20
21
  multer(options: PlatformMulterSettings): PlatformMulter;
21
22
  statics(path: string, options: PlatformStaticsOptions): this;
22
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/platform-koa",
3
- "version": "6.107.3",
3
+ "version": "6.108.0",
4
4
  "description": "Koa package for Ts.ED framework",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
@@ -50,23 +50,23 @@
50
50
  "homepage": "https://github.com/tsedio/tsed/tree/production/packages/platform/platform-koa",
51
51
  "repository": "https://github.com/tsedio/tsed",
52
52
  "devDependencies": {
53
- "@koa/cors": "3.1.0",
54
- "@tsed/common": "6.107.3",
55
- "@tsed/core": "6.107.3",
56
- "@tsed/di": "6.107.3",
57
- "@tsed/platform-test-utils": "6.107.3",
58
- "@types/koa": "2.11.3",
59
- "@types/koa-bodyparser": "4.3.0",
53
+ "@koa/cors": "3.3.0",
54
+ "@tsed/common": "6.108.0",
55
+ "@tsed/core": "6.108.0",
56
+ "@tsed/di": "6.108.0",
57
+ "@tsed/platform-test-utils": "6.108.0",
58
+ "@types/koa": "2.13.4",
59
+ "@types/koa-bodyparser": "4.3.7",
60
60
  "@types/koa-compose": "3.2.5",
61
- "@types/koa-compress": "4.0.0",
62
- "@types/koa-json": "2.0.18",
61
+ "@types/koa-compress": "4.0.3",
62
+ "@types/koa-json": "2.0.20",
63
63
  "@types/koa-mount": "4.0.1",
64
- "@types/koa-send": "4.1.2",
65
- "@types/koa-session": "5.10.2",
66
- "@types/koa__router": "8.0.2",
67
- "koa": "2.13.0",
64
+ "@types/koa-send": "4.1.3",
65
+ "@types/koa-session": "5.10.6",
66
+ "@types/koa__router": "8.0.11",
67
+ "koa": "2.13.4",
68
68
  "koa-bodyparser": "4.3.0",
69
- "koa-compress": "5.0.1",
69
+ "koa-compress": "5.1.0",
70
70
  "koa-override": "3.0.0",
71
71
  "koa-qs": "^3.0.0",
72
72
  "koa-session": "6.2.0"
@@ -76,21 +76,44 @@
76
76
  "encodeurl": "^1.0.2",
77
77
  "koa-send": "5.0.1",
78
78
  "multer": "^1.4.2",
79
- "tslib": "2.2.0"
79
+ "tslib": "2.3.1"
80
80
  },
81
81
  "peerDependencies": {
82
- "@tsed/common": "^6.107.3",
83
- "@tsed/core": "^6.107.3",
84
- "@tsed/di": "^6.107.3",
85
- "@tsed/json-mapper": "^6.107.3",
86
- "@tsed/logger": ">=6.1.0",
87
- "@tsed/openspec": "^6.107.3",
88
- "@tsed/schema": "^6.107.3",
82
+ "@tsed/common": "^6.108.0",
83
+ "@tsed/core": "^6.108.0",
84
+ "@tsed/di": "^6.108.0",
85
+ "@tsed/json-mapper": "^6.108.0",
86
+ "@tsed/logger": ">=6.1.1",
87
+ "@tsed/openspec": "^6.108.0",
88
+ "@tsed/schema": "^6.108.0",
89
89
  "koa": ">=2.13.0",
90
90
  "koa-bodyparser": ">=4.3.0",
91
91
  "koa-compress": ">=5.0.1",
92
92
  "koa-override": ">=3.0.0",
93
93
  "koa-qs": ">=3.0.0",
94
94
  "koa-session": ">=6.2.0"
95
+ },
96
+ "peerDependenciesMeta": {
97
+ "@tsed/common": {
98
+ "optional": false
99
+ },
100
+ "@tsed/core": {
101
+ "optional": false
102
+ },
103
+ "@tsed/di": {
104
+ "optional": false
105
+ },
106
+ "@tsed/json-mapper": {
107
+ "optional": false
108
+ },
109
+ "@tsed/openspec": {
110
+ "optional": false
111
+ },
112
+ "@tsed/schema": {
113
+ "optional": false
114
+ },
115
+ "@tsed/logger": {
116
+ "optional": false
117
+ }
95
118
  }
96
119
  }