@tsed/platform-koa 6.87.1 → 6.89.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.
Files changed (138) hide show
  1. package/lib/{components → cjs/components}/PlatformKoa.d.ts +0 -0
  2. package/lib/{components → cjs/components}/PlatformKoa.js +1 -1
  3. package/lib/cjs/components/PlatformKoa.js.map +1 -0
  4. package/lib/{decorators → cjs/decorators}/caseSensitive.d.ts +0 -0
  5. package/lib/{decorators → cjs/decorators}/caseSensitive.js +1 -1
  6. package/lib/cjs/decorators/caseSensitive.js.map +1 -0
  7. package/lib/{decorators → cjs/decorators}/ctx.d.ts +0 -0
  8. package/lib/{decorators → cjs/decorators}/ctx.js +1 -1
  9. package/lib/cjs/decorators/ctx.js.map +1 -0
  10. package/lib/{decorators → cjs/decorators}/index.d.ts +0 -0
  11. package/lib/cjs/decorators/index.js +9 -0
  12. package/lib/cjs/decorators/index.js.map +1 -0
  13. package/lib/{decorators → cjs/decorators}/routerSettings.d.ts +0 -0
  14. package/lib/{decorators → cjs/decorators}/routerSettings.js +1 -1
  15. package/lib/cjs/decorators/routerSettings.js.map +1 -0
  16. package/lib/{decorators → cjs/decorators}/state.d.ts +0 -0
  17. package/lib/{decorators → cjs/decorators}/state.js +0 -0
  18. package/lib/cjs/decorators/state.js.map +1 -0
  19. package/lib/{decorators → cjs/decorators}/strict.d.ts +0 -0
  20. package/lib/{decorators → cjs/decorators}/strict.js +1 -1
  21. package/lib/cjs/decorators/strict.js.map +1 -0
  22. package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
  23. package/lib/{index.js → cjs/index.js} +4 -4
  24. package/lib/cjs/index.js.map +1 -0
  25. package/lib/{interfaces → cjs/interfaces}/PlatformKoaSettings.d.ts +0 -0
  26. package/lib/{interfaces → cjs/interfaces}/PlatformKoaSettings.js +0 -0
  27. package/lib/cjs/interfaces/PlatformKoaSettings.js.map +1 -0
  28. package/lib/{interfaces → cjs/interfaces}/index.d.ts +0 -0
  29. package/lib/{interfaces → cjs/interfaces}/index.js +1 -1
  30. package/lib/cjs/interfaces/index.js.map +1 -0
  31. package/lib/{middlewares → cjs/middlewares}/resourceNotFoundMiddleware.d.ts +0 -0
  32. package/lib/{middlewares → cjs/middlewares}/resourceNotFoundMiddleware.js +0 -0
  33. package/lib/cjs/middlewares/resourceNotFoundMiddleware.js.map +1 -0
  34. package/lib/{middlewares → cjs/middlewares}/staticsMiddleware.d.ts +0 -0
  35. package/lib/{middlewares → cjs/middlewares}/staticsMiddleware.js +2 -2
  36. package/lib/cjs/middlewares/staticsMiddleware.js.map +1 -0
  37. package/lib/{services → cjs/services}/PlatformKoaApplication.d.ts +0 -0
  38. package/lib/{services → cjs/services}/PlatformKoaApplication.js +5 -4
  39. package/lib/cjs/services/PlatformKoaApplication.js.map +1 -0
  40. package/lib/{services → cjs/services}/PlatformKoaHandler.d.ts +0 -0
  41. package/lib/{services → cjs/services}/PlatformKoaHandler.js +0 -0
  42. package/lib/cjs/services/PlatformKoaHandler.js.map +1 -0
  43. package/lib/{services → cjs/services}/PlatformKoaRequest.d.ts +1 -1
  44. package/lib/cjs/services/PlatformKoaRequest.js +44 -0
  45. package/lib/cjs/services/PlatformKoaRequest.js.map +1 -0
  46. package/lib/{services → cjs/services}/PlatformKoaResponse.d.ts +2 -2
  47. package/lib/{services → cjs/services}/PlatformKoaResponse.js +8 -8
  48. package/lib/cjs/services/PlatformKoaResponse.js.map +1 -0
  49. package/lib/{services → cjs/services}/PlatformKoaRouter.d.ts +0 -0
  50. package/lib/{services → cjs/services}/PlatformKoaRouter.js +7 -7
  51. package/lib/cjs/services/PlatformKoaRouter.js.map +1 -0
  52. package/lib/{services → cjs/services}/index.d.ts +0 -0
  53. package/lib/cjs/services/index.js +9 -0
  54. package/lib/cjs/services/index.js.map +1 -0
  55. package/lib/{utils → cjs/utils}/multer.d.ts +0 -0
  56. package/lib/{utils → cjs/utils}/multer.js +1 -1
  57. package/lib/cjs/utils/multer.js.map +1 -0
  58. package/lib/esm/components/PlatformKoa.js +74 -0
  59. package/lib/esm/components/PlatformKoa.js.map +1 -0
  60. package/lib/esm/decorators/caseSensitive.js +26 -0
  61. package/lib/esm/decorators/caseSensitive.js.map +1 -0
  62. package/lib/esm/decorators/ctx.js +27 -0
  63. package/lib/esm/decorators/ctx.js.map +1 -0
  64. package/lib/esm/decorators/index.js +6 -0
  65. package/lib/esm/decorators/index.js.map +1 -0
  66. package/lib/esm/decorators/routerSettings.js +27 -0
  67. package/lib/esm/decorators/routerSettings.js.map +1 -0
  68. package/lib/esm/decorators/state.js +5 -0
  69. package/lib/esm/decorators/state.js.map +1 -0
  70. package/lib/esm/decorators/strict.js +27 -0
  71. package/lib/esm/decorators/strict.js.map +1 -0
  72. package/lib/esm/index.js +13 -0
  73. package/lib/esm/index.js.map +1 -0
  74. package/lib/esm/interfaces/PlatformKoaSettings.js +2 -0
  75. package/lib/esm/interfaces/PlatformKoaSettings.js.map +1 -0
  76. package/lib/esm/interfaces/index.js +2 -0
  77. package/lib/esm/interfaces/index.js.map +1 -0
  78. package/lib/esm/middlewares/resourceNotFoundMiddleware.js +16 -0
  79. package/lib/esm/middlewares/resourceNotFoundMiddleware.js.map +1 -0
  80. package/lib/esm/middlewares/staticsMiddleware.js +30 -0
  81. package/lib/esm/middlewares/staticsMiddleware.js.map +1 -0
  82. package/lib/esm/services/PlatformKoaApplication.js +29 -0
  83. package/lib/esm/services/PlatformKoaApplication.js.map +1 -0
  84. package/lib/esm/services/PlatformKoaHandler.js +56 -0
  85. package/lib/esm/services/PlatformKoaHandler.js.map +1 -0
  86. package/lib/esm/services/PlatformKoaRequest.js +40 -0
  87. package/lib/esm/services/PlatformKoaRequest.js.map +1 -0
  88. package/lib/esm/services/PlatformKoaResponse.js +101 -0
  89. package/lib/esm/services/PlatformKoaResponse.js.map +1 -0
  90. package/lib/esm/services/PlatformKoaRouter.js +42 -0
  91. package/lib/esm/services/PlatformKoaRouter.js.map +1 -0
  92. package/lib/esm/services/index.js +6 -0
  93. package/lib/esm/services/index.js.map +1 -0
  94. package/lib/esm/utils/multer.js +51 -0
  95. package/lib/esm/utils/multer.js.map +1 -0
  96. package/lib/types/components/PlatformKoa.d.ts +38 -0
  97. package/lib/types/decorators/caseSensitive.d.ts +22 -0
  98. package/lib/types/decorators/ctx.d.ts +19 -0
  99. package/lib/types/decorators/index.d.ts +5 -0
  100. package/lib/types/decorators/routerSettings.d.ts +24 -0
  101. package/lib/types/decorators/state.d.ts +38 -0
  102. package/lib/types/decorators/strict.d.ts +23 -0
  103. package/lib/types/index.d.ts +4 -0
  104. package/lib/types/interfaces/PlatformKoaSettings.d.ts +8 -0
  105. package/lib/types/interfaces/index.d.ts +15 -0
  106. package/lib/types/middlewares/resourceNotFoundMiddleware.d.ts +6 -0
  107. package/lib/types/middlewares/staticsMiddleware.d.ts +6 -0
  108. package/lib/types/services/PlatformKoaApplication.d.ts +22 -0
  109. package/lib/types/services/PlatformKoaHandler.d.ts +10 -0
  110. package/lib/types/services/PlatformKoaRequest.d.ts +34 -0
  111. package/lib/types/services/PlatformKoaResponse.d.ts +57 -0
  112. package/lib/types/services/PlatformKoaRouter.d.ts +22 -0
  113. package/lib/types/services/index.d.ts +5 -0
  114. package/lib/types/utils/multer.d.ts +4 -0
  115. package/package.json +26 -18
  116. package/tsconfig.compile.esm.json +23 -0
  117. package/lib/components/PlatformKoa.js.map +0 -1
  118. package/lib/decorators/caseSensitive.js.map +0 -1
  119. package/lib/decorators/ctx.js.map +0 -1
  120. package/lib/decorators/index.js +0 -9
  121. package/lib/decorators/index.js.map +0 -1
  122. package/lib/decorators/routerSettings.js.map +0 -1
  123. package/lib/decorators/state.js.map +0 -1
  124. package/lib/decorators/strict.js.map +0 -1
  125. package/lib/index.js.map +0 -1
  126. package/lib/interfaces/PlatformKoaSettings.js.map +0 -1
  127. package/lib/interfaces/index.js.map +0 -1
  128. package/lib/middlewares/resourceNotFoundMiddleware.js.map +0 -1
  129. package/lib/middlewares/staticsMiddleware.js.map +0 -1
  130. package/lib/services/PlatformKoaApplication.js.map +0 -1
  131. package/lib/services/PlatformKoaHandler.js.map +0 -1
  132. package/lib/services/PlatformKoaRequest.js +0 -44
  133. package/lib/services/PlatformKoaRequest.js.map +0 -1
  134. package/lib/services/PlatformKoaResponse.js.map +0 -1
  135. package/lib/services/PlatformKoaRouter.js.map +0 -1
  136. package/lib/services/index.js +0 -9
  137. package/lib/services/index.js.map +0 -1
  138. package/lib/utils/multer.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformKoaResponse.js","sourceRoot":"","sources":["../../src/services/PlatformKoaResponse.ts"],"names":[],"mappings":";;;;;AAAA,yCAA6D;AAG7D,yCAA8C;AAE9C,MAAM,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAQvC;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,yBAA8B;IAGrE,YAAY,KAAoB;QAC9B,KAAK,CAAC,KAAK,CAAC,CAAC;QAHf,uBAAkB;QAIhB,+BAAA,IAAI,QAAQ,IAAI,CAAC,GAAG,CAAC,GAAG,EAAC;IAC3B,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;IACzB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,2CAAU,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,CAAC;QAE5B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U,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;QAE9C,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA5GD,kDA4GC","sourcesContent":["import {IncomingEvent, PlatformResponse} from \"@tsed/common\";\nimport {ServerResponse} from \"http\";\nimport Koa from \"koa\";\nimport {getStatusMessage} from \"@tsed/schema\";\n\nconst encodeUrl = require(\"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) {\n super(event);\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 +0,0 @@
1
- {"version":3,"file":"PlatformKoaRouter.js","sourceRoot":"","sources":["../../src/services/PlatformKoaRouter.ts"],"names":[],"mappings":";;;;AAAA,iEAAoC;AAGpC,yCAOsB;AACtB,iCAA+C;AAE/C,wEAAmE;AACnE,4CAA0C;AAY1C,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,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,uBAAyB;IAC9D,YACE,QAAyB,EACR,aAA4B,EACZ,aAAkB;;QAEnD,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEhB,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,CAAA,MAAA,aAAa,CAAC,GAAG,0CAAE,MAAM,KAAI,EAAE,EAAE,aAAa,CAAC,CAAC;QAClF,IAAI,CAAC,SAAS,GAAG,IAAI,gBAAS,CAAC,OAAO,CAAQ,CAAC;IACjD,CAAC;IAED,QAAQ;QACN,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,CAAC,OAA+B;QACpC,OAAO,kBAAS,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,CAAC,IAAY,EAAE,OAA+B;QACnD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,qCAAiB,CAAC,OAAO,CAAQ,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAzBY,iBAAiB;IAGzB,mBAAA,kBAAa,EAAE,CAAA;IACf,mBAAA,WAAM,CAAC,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,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./PlatformKoaApplication"), exports);
5
- tslib_1.__exportStar(require("./PlatformKoaHandler"), exports);
6
- tslib_1.__exportStar(require("./PlatformKoaRouter"), exports);
7
- tslib_1.__exportStar(require("./PlatformKoaRequest"), exports);
8
- tslib_1.__exportStar(require("./PlatformKoaResponse"), exports);
9
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;AAAA,mEAAyC;AACzC,+DAAqC;AACrC,8DAAoC;AACpC,+DAAqC;AACrC,gEAAsC","sourcesContent":["export * from \"./PlatformKoaApplication\";\nexport * from \"./PlatformKoaHandler\";\nexport * from \"./PlatformKoaRouter\";\nexport * from \"./PlatformKoaRequest\";\nexport * from \"./PlatformKoaResponse\";\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"multer.js","sourceRoot":"","sources":["../../src/utils/multer.ts"],"names":[],"mappings":";;;AACA,+BAA+B;AAE/B;;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,CAA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AAW,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\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 = require(\"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"]}