@tsed/common 7.0.0-beta.1 → 7.0.0-beta.10

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 (253) hide show
  1. package/lib/cjs/builder/PlatformBuilder.js +38 -27
  2. package/lib/cjs/builder/PlatformBuilder.js.map +1 -1
  3. package/lib/cjs/builder/PlatformControllerBuilder.js +5 -8
  4. package/lib/cjs/builder/PlatformControllerBuilder.js.map +1 -1
  5. package/lib/cjs/config/interfaces/PlatformMulterSettings.js.map +1 -1
  6. package/lib/cjs/config/services/PlatformConfiguration.js +2 -2
  7. package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -1
  8. package/lib/cjs/decorators/multer/multipartFile.js.map +1 -1
  9. package/lib/cjs/domain/EndpointMetadata.js +2 -66
  10. package/lib/cjs/domain/EndpointMetadata.js.map +1 -1
  11. package/lib/cjs/domain/PlatformContext.js.map +1 -1
  12. package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -1
  13. package/lib/cjs/exports.js +31 -0
  14. package/lib/cjs/exports.js.map +1 -0
  15. package/lib/cjs/index.js +66 -30
  16. package/lib/cjs/index.js.map +1 -1
  17. package/lib/cjs/interfaces/PlatformRouteOptions.js.map +1 -1
  18. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js +8 -8
  19. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
  20. package/lib/cjs/middlewares/PlatformMulterMiddleware.js +25 -13
  21. package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -1
  22. package/lib/cjs/middlewares/__mock__/FakeCtrl.js +1 -1
  23. package/lib/cjs/middlewares/bindEndpointMiddleware.js.map +1 -1
  24. package/lib/cjs/package.json +3 -0
  25. package/lib/cjs/services/FakeAdapter.js +55 -0
  26. package/lib/cjs/services/FakeAdapter.js.map +1 -0
  27. package/lib/cjs/services/Platform.js +30 -9
  28. package/lib/cjs/services/Platform.js.map +1 -1
  29. package/lib/cjs/services/PlatformAdapter.js +14 -0
  30. package/lib/cjs/services/PlatformAdapter.js.map +1 -0
  31. package/lib/cjs/services/PlatformApplication.js +9 -11
  32. package/lib/cjs/services/PlatformApplication.js.map +1 -1
  33. package/lib/cjs/services/PlatformHandler.js +11 -9
  34. package/lib/cjs/services/PlatformHandler.js.map +1 -1
  35. package/lib/cjs/services/PlatformMiddlewaresChain.js +56 -15
  36. package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -1
  37. package/lib/cjs/services/PlatformRequest.js +2 -2
  38. package/lib/cjs/services/PlatformResponse.js +5 -5
  39. package/lib/cjs/services/PlatformResponse.js.map +1 -1
  40. package/lib/cjs/services/PlatformRouter.js +14 -32
  41. package/lib/cjs/services/PlatformRouter.js.map +1 -1
  42. package/lib/cjs/services/PlatformTest.js +3 -2
  43. package/lib/cjs/services/PlatformTest.js.map +1 -1
  44. package/lib/cjs/utils/__mock__/Test1.js +8 -0
  45. package/lib/cjs/utils/__mock__/Test1.js.map +1 -0
  46. package/lib/cjs/utils/__mock__/Test2.js +8 -0
  47. package/lib/cjs/utils/__mock__/Test2.js.map +1 -0
  48. package/lib/cjs/utils/createContext.js +2 -2
  49. package/lib/cjs/utils/createContext.js.map +1 -1
  50. package/lib/cjs/utils/createHandlerMetadata.js +2 -2
  51. package/lib/cjs/utils/createHandlerMetadata.js.map +1 -1
  52. package/lib/cjs/utils/createHttpServer.js +3 -8
  53. package/lib/cjs/utils/createHttpServer.js.map +1 -1
  54. package/lib/cjs/utils/createHttpsServer.js +3 -8
  55. package/lib/cjs/utils/createHttpsServer.js.map +1 -1
  56. package/lib/cjs/utils/createInjector.js +11 -3
  57. package/lib/cjs/utils/createInjector.js.map +1 -1
  58. package/lib/cjs/utils/importProviders.js +29 -0
  59. package/lib/cjs/utils/importProviders.js.map +1 -0
  60. package/lib/cjs/utils/setResponseHeaders.js.map +1 -1
  61. package/lib/esm/builder/PlatformBuilder.js +25 -14
  62. package/lib/esm/builder/PlatformBuilder.js.map +1 -1
  63. package/lib/esm/builder/PlatformControllerBuilder.js +8 -11
  64. package/lib/esm/builder/PlatformControllerBuilder.js.map +1 -1
  65. package/lib/esm/config/interfaces/PlatformMulterSettings.js.map +1 -1
  66. package/lib/esm/config/services/PlatformConfiguration.js.map +1 -1
  67. package/lib/esm/decorators/multer/multerFileSize.js +1 -1
  68. package/lib/esm/decorators/multer/multerOptions.js +1 -1
  69. package/lib/esm/decorators/multer/multipartFile.js +1 -1
  70. package/lib/esm/decorators/multer/multipartFile.js.map +1 -1
  71. package/lib/esm/domain/ControllerProvider.js +1 -1
  72. package/lib/esm/domain/EndpointMetadata.js +1 -66
  73. package/lib/esm/domain/EndpointMetadata.js.map +1 -1
  74. package/lib/esm/domain/HandlerMetadata.js +1 -1
  75. package/lib/esm/domain/PlatformContext.js +3 -3
  76. package/lib/esm/domain/PlatformContext.js.map +1 -1
  77. package/lib/esm/domain/PlatformRouteDetails.js.map +1 -1
  78. package/lib/esm/exports.js +13 -0
  79. package/lib/esm/exports.js.map +1 -0
  80. package/lib/esm/index.js +66 -27
  81. package/lib/esm/index.js.map +1 -1
  82. package/lib/esm/interfaces/PlatformRouteOptions.js.map +1 -1
  83. package/lib/esm/middlewares/PlatformMulterMiddleware.js +16 -5
  84. package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +1 -1
  85. package/lib/esm/middlewares/bindEndpointMiddleware.js.map +1 -1
  86. package/lib/esm/package.json +3 -0
  87. package/lib/esm/services/FakeAdapter.js +51 -0
  88. package/lib/esm/services/FakeAdapter.js.map +1 -0
  89. package/lib/esm/services/Platform.js +31 -10
  90. package/lib/esm/services/Platform.js.map +1 -1
  91. package/lib/esm/services/PlatformAdapter.js +10 -0
  92. package/lib/esm/services/PlatformAdapter.js.map +1 -0
  93. package/lib/esm/services/PlatformApplication.js +11 -13
  94. package/lib/esm/services/PlatformApplication.js.map +1 -1
  95. package/lib/esm/services/PlatformHandler.js +13 -11
  96. package/lib/esm/services/PlatformHandler.js.map +1 -1
  97. package/lib/esm/services/PlatformMiddlewaresChain.js +61 -20
  98. package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -1
  99. package/lib/esm/services/PlatformResponse.js +1 -1
  100. package/lib/esm/services/PlatformResponse.js.map +1 -1
  101. package/lib/esm/services/PlatformRouter.js +13 -31
  102. package/lib/esm/services/PlatformRouter.js.map +1 -1
  103. package/lib/esm/services/PlatformTest.js +7 -7
  104. package/lib/esm/services/PlatformTest.js.map +1 -1
  105. package/lib/esm/utils/__mock__/Test1.js +4 -0
  106. package/lib/esm/utils/__mock__/Test1.js.map +1 -0
  107. package/lib/esm/utils/__mock__/Test2.js +4 -0
  108. package/lib/esm/utils/__mock__/Test2.js.map +1 -0
  109. package/lib/esm/utils/createContext.js +5 -5
  110. package/lib/esm/utils/createContext.js.map +1 -1
  111. package/lib/esm/utils/createHandlerMetadata.js +3 -3
  112. package/lib/esm/utils/createHandlerMetadata.js.map +1 -1
  113. package/lib/esm/utils/createHttpServer.js +3 -8
  114. package/lib/esm/utils/createHttpServer.js.map +1 -1
  115. package/lib/esm/utils/createHttpsServer.js +3 -8
  116. package/lib/esm/utils/createHttpsServer.js.map +1 -1
  117. package/lib/esm/utils/createInjector.js +18 -10
  118. package/lib/esm/utils/createInjector.js.map +1 -1
  119. package/lib/esm/utils/importProviders.js +25 -0
  120. package/lib/esm/utils/importProviders.js.map +1 -0
  121. package/lib/esm/utils/setResponseHeaders.js.map +1 -1
  122. package/lib/esm/utils/useCtxHandler.js +1 -1
  123. package/lib/types/builder/PlatformBuilder.d.ts +7 -6
  124. package/lib/types/builder/PlatformControllerBuilder.d.ts +2 -1
  125. package/lib/types/config/interfaces/PlatformMulterSettings.d.ts +6 -130
  126. package/lib/types/config/services/PlatformConfiguration.d.ts +2 -1
  127. package/lib/types/domain/EndpointMetadata.d.ts +1 -50
  128. package/lib/types/domain/PlatformContext.d.ts +1 -1
  129. package/lib/types/domain/PlatformRouteDetails.d.ts +2 -3
  130. package/lib/types/exports.d.ts +12 -0
  131. package/lib/types/index.d.ts +63 -17
  132. package/lib/types/interfaces/PlatformRouteOptions.d.ts +1 -1
  133. package/lib/types/middlewares/PlatformMulterMiddleware.d.ts +8 -3
  134. package/lib/types/middlewares/bindEndpointMiddleware.d.ts +2 -1
  135. package/lib/types/services/FakeAdapter.d.ts +30 -0
  136. package/lib/types/services/Platform.d.ts +10 -1
  137. package/lib/types/services/PlatformAdapter.d.ts +47 -0
  138. package/lib/types/services/PlatformApplication.d.ts +3 -3
  139. package/lib/types/services/PlatformHandler.d.ts +1 -1
  140. package/lib/types/services/PlatformMiddlewaresChain.d.ts +6 -2
  141. package/lib/types/services/PlatformResponse.d.ts +6 -6
  142. package/lib/types/services/PlatformRouter.d.ts +10 -7
  143. package/lib/types/services/PlatformTest.d.ts +2 -2
  144. package/lib/types/utils/__mock__/Test1.d.ts +3 -0
  145. package/lib/types/utils/__mock__/Test2.d.ts +3 -0
  146. package/lib/types/utils/createHandlerMetadata.d.ts +1 -1
  147. package/lib/types/utils/createHttpServer.d.ts +1 -1
  148. package/lib/types/utils/createHttpsServer.d.ts +2 -1
  149. package/lib/types/utils/createInjector.d.ts +5 -3
  150. package/lib/types/utils/importProviders.d.ts +10 -0
  151. package/package.json +38 -26
  152. package/readme.md +50 -57
  153. package/tsconfig.compile.esm.json +2 -12
  154. package/lib/cjs/config/index.js +0 -7
  155. package/lib/cjs/config/index.js.map +0 -1
  156. package/lib/cjs/config/interfaces/index.js +0 -8
  157. package/lib/cjs/config/interfaces/index.js.map +0 -1
  158. package/lib/cjs/decorators/httpServer.js +0 -32
  159. package/lib/cjs/decorators/httpServer.js.map +0 -1
  160. package/lib/cjs/decorators/httpsServer.js +0 -32
  161. package/lib/cjs/decorators/httpsServer.js.map +0 -1
  162. package/lib/cjs/decorators/index.js +0 -21
  163. package/lib/cjs/decorators/index.js.map +0 -1
  164. package/lib/cjs/decorators/method/acceptMime.js +0 -28
  165. package/lib/cjs/decorators/method/acceptMime.js.map +0 -1
  166. package/lib/cjs/decorators/method/endpointFn.js +0 -15
  167. package/lib/cjs/decorators/method/endpointFn.js.map +0 -1
  168. package/lib/cjs/decorators/method/location.js +0 -6
  169. package/lib/cjs/decorators/method/location.js.map +0 -1
  170. package/lib/cjs/decorators/method/redirect.js +0 -6
  171. package/lib/cjs/decorators/method/redirect.js.map +0 -1
  172. package/lib/cjs/decorators/method/route.js +0 -13
  173. package/lib/cjs/decorators/method/route.js.map +0 -1
  174. package/lib/cjs/decorators/method/view.js +0 -34
  175. package/lib/cjs/decorators/method/view.js.map +0 -1
  176. package/lib/cjs/decorators/multer/index.js +0 -7
  177. package/lib/cjs/decorators/multer/index.js.map +0 -1
  178. package/lib/cjs/domain/index.js +0 -10
  179. package/lib/cjs/domain/index.js.map +0 -1
  180. package/lib/cjs/interfaces/PathType.js +0 -3
  181. package/lib/cjs/interfaces/PathType.js.map +0 -1
  182. package/lib/cjs/interfaces/PlatformAdapter.js +0 -3
  183. package/lib/cjs/interfaces/PlatformAdapter.js.map +0 -1
  184. package/lib/cjs/interfaces/index.js +0 -21
  185. package/lib/cjs/interfaces/index.js.map +0 -1
  186. package/lib/cjs/middlewares/index.js +0 -7
  187. package/lib/cjs/middlewares/index.js.map +0 -1
  188. package/lib/cjs/services/FakeRawDriver.js +0 -26
  189. package/lib/cjs/services/FakeRawDriver.js.map +0 -1
  190. package/lib/cjs/services/index.js +0 -12
  191. package/lib/cjs/services/index.js.map +0 -1
  192. package/lib/cjs/utils/index.js +0 -11
  193. package/lib/cjs/utils/index.js.map +0 -1
  194. package/lib/esm/config/index.js +0 -4
  195. package/lib/esm/config/index.js.map +0 -1
  196. package/lib/esm/config/interfaces/index.js +0 -5
  197. package/lib/esm/config/interfaces/index.js.map +0 -1
  198. package/lib/esm/decorators/httpServer.js +0 -28
  199. package/lib/esm/decorators/httpServer.js.map +0 -1
  200. package/lib/esm/decorators/httpsServer.js +0 -28
  201. package/lib/esm/decorators/httpsServer.js.map +0 -1
  202. package/lib/esm/decorators/index.js +0 -18
  203. package/lib/esm/decorators/index.js.map +0 -1
  204. package/lib/esm/decorators/method/acceptMime.js +0 -24
  205. package/lib/esm/decorators/method/acceptMime.js.map +0 -1
  206. package/lib/esm/decorators/method/endpointFn.js +0 -11
  207. package/lib/esm/decorators/method/endpointFn.js.map +0 -1
  208. package/lib/esm/decorators/method/location.js +0 -2
  209. package/lib/esm/decorators/method/location.js.map +0 -1
  210. package/lib/esm/decorators/method/redirect.js +0 -2
  211. package/lib/esm/decorators/method/redirect.js.map +0 -1
  212. package/lib/esm/decorators/method/route.js +0 -2
  213. package/lib/esm/decorators/method/route.js.map +0 -1
  214. package/lib/esm/decorators/method/view.js +0 -30
  215. package/lib/esm/decorators/method/view.js.map +0 -1
  216. package/lib/esm/decorators/multer/index.js +0 -4
  217. package/lib/esm/decorators/multer/index.js.map +0 -1
  218. package/lib/esm/domain/index.js +0 -7
  219. package/lib/esm/domain/index.js.map +0 -1
  220. package/lib/esm/interfaces/PathType.js +0 -2
  221. package/lib/esm/interfaces/PathType.js.map +0 -1
  222. package/lib/esm/interfaces/PlatformAdapter.js +0 -2
  223. package/lib/esm/interfaces/PlatformAdapter.js.map +0 -1
  224. package/lib/esm/interfaces/index.js +0 -18
  225. package/lib/esm/interfaces/index.js.map +0 -1
  226. package/lib/esm/middlewares/index.js +0 -4
  227. package/lib/esm/middlewares/index.js.map +0 -1
  228. package/lib/esm/services/FakeRawDriver.js +0 -22
  229. package/lib/esm/services/FakeRawDriver.js.map +0 -1
  230. package/lib/esm/services/index.js +0 -9
  231. package/lib/esm/services/index.js.map +0 -1
  232. package/lib/esm/utils/index.js +0 -8
  233. package/lib/esm/utils/index.js.map +0 -1
  234. package/lib/types/config/index.d.ts +0 -3
  235. package/lib/types/config/interfaces/index.d.ts +0 -97
  236. package/lib/types/decorators/httpServer.d.ts +0 -28
  237. package/lib/types/decorators/httpsServer.d.ts +0 -28
  238. package/lib/types/decorators/index.d.ts +0 -14
  239. package/lib/types/decorators/method/acceptMime.d.ts +0 -19
  240. package/lib/types/decorators/method/endpointFn.d.ts +0 -9
  241. package/lib/types/decorators/method/location.d.ts +0 -1
  242. package/lib/types/decorators/method/redirect.d.ts +0 -1
  243. package/lib/types/decorators/method/route.d.ts +0 -1
  244. package/lib/types/decorators/method/view.d.ts +0 -25
  245. package/lib/types/decorators/multer/index.d.ts +0 -3
  246. package/lib/types/domain/index.d.ts +0 -6
  247. package/lib/types/interfaces/PathType.d.ts +0 -1
  248. package/lib/types/interfaces/PlatformAdapter.d.ts +0 -19
  249. package/lib/types/interfaces/index.d.ts +0 -17
  250. package/lib/types/middlewares/index.d.ts +0 -3
  251. package/lib/types/services/FakeRawDriver.d.ts +0 -15
  252. package/lib/types/services/index.d.ts +0 -8
  253. package/lib/types/utils/index.d.ts +0 -7
@@ -1,4 +1,4 @@
1
- import { MulterOptions } from "./multerOptions";
1
+ import { MulterOptions } from "./multerOptions.js";
2
2
  /**
3
3
  * Define file size limit.
4
4
  *
@@ -1,5 +1,5 @@
1
1
  import { StoreMerge } from "@tsed/core";
2
- import { PlatformMulterMiddleware } from "../../middlewares/PlatformMulterMiddleware";
2
+ import { PlatformMulterMiddleware } from "../../middlewares/PlatformMulterMiddleware.js";
3
3
  /**
4
4
  * Define multer option for all MultipartFile
5
5
  *
@@ -1,7 +1,7 @@
1
1
  import { Metadata, StoreMerge, useDecorators, useMethodDecorators } from "@tsed/core";
2
2
  import { ParamTypes, UseParam } from "@tsed/platform-params";
3
3
  import { InFile } from "@tsed/schema";
4
- import { PlatformMulterMiddleware } from "../../middlewares/PlatformMulterMiddleware";
4
+ import { PlatformMulterMiddleware } from "../../middlewares/PlatformMulterMiddleware.js";
5
5
  function mapOptions(name, maxCount) {
6
6
  return {
7
7
  fields: [
@@ -1 +1 @@
1
- {"version":3,"file":"multipartFile.js","sourceRoot":"","sources":["../../../../src/decorators/multer/multipartFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,mBAAmB,EAAC,MAA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AAG,IAAI,CAAC,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {DecoratorParameters, Metadata, StoreMerge, useDecorators, useMethodDecorators} from \"@tsed/core\";\nimport {ParamTypes, UseParam} from \"@tsed/platform-params\";\nimport {Consumes, InFile, Returns} from \"@tsed/schema\";\nimport {PlatformMulterFile} from \"../../config/interfaces/PlatformMulterSettings\";\nimport {MulterInputOptions, PlatformMulterMiddleware} from \"../../middlewares/PlatformMulterMiddleware\";\n\nfunction mapOptions(name: string, maxCount: number | undefined): MulterInputOptions {\n return {\n fields: [\n {\n name,\n maxCount\n }\n ]\n };\n}\n\n/**\n * Define a parameter as Multipart file.\n *\n * ```typescript\n * import {Controller, Post} from \"@tsed/common\";\n * import {MulterOptions, MultipartFile} from \"@tsed/common\";\n * import {Multer} from \"@types/multer\";\n *\n * type MulterFile = Express.Multer.File;\n *\n * @Controller('/')\n * class MyCtrl {\n * @Post('/file')\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile) {\n *\n * }\n *\n * @Post('/file')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile) {\n *\n * }\n *\n * @Post('/file2')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile, @MultipartFile(\"file2\") file2: MulterFile) {\n *\n * }\n *\n * @Post('/files')\n * private uploadFile(@MultipartFile(\"file1\") files: MulterFile[]) {\n *\n * }\n * }\n * ```\n *\n * > See the tutorial on the [multer configuration](/tutorials/multer.md).\n *\n * @param name\n * @param maxCount\n * @returns Function\n * @decorator\n * @input\n */\nexport function MultipartFile(name: string, maxCount?: number): ParameterDecorator {\n return (...args: DecoratorParameters): void => {\n const [target, propertyKey, index] = args;\n const multiple = Metadata.getParamTypes(target, propertyKey)[index as number] === Array;\n\n name = (typeof name === \"object\" ? undefined : name)!;\n\n const expression = [name, !multiple && \"0\"].filter(Boolean).join(\".\");\n\n const decorators = useDecorators(\n InFile(name),\n useMethodDecorators(StoreMerge(PlatformMulterMiddleware, mapOptions(name, maxCount))),\n UseParam({\n paramType: ParamTypes.FILES,\n dataPath: \"$ctx.request.files\",\n expression,\n useValidation: true\n })\n );\n\n decorators(...args);\n };\n}\n\nexport type MultipartFile = PlatformMulterFile;\n"]}
1
+ {"version":3,"file":"multipartFile.js","sourceRoot":"","sources":["../../../../src/decorators/multer/multipartFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,mBAAmB,EAAC,MAAM,YAAY,CAAC;AACzG,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAqB,wBAAwB,EAAC,MAAM,4CAA4C,CAAC;AAExG,SAAS,UAAU,CAAC,IAAY,EAAE,QAA4B;IAC5D,OAAO;QACL,MAAM,EAAE;YACN;gBACE,IAAI;gBACJ,QAAQ;aACT;SACF;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,QAAiB;IAC3D,OAAO,CAAC,GAAG,IAAyB,EAAQ,EAAE;QAC5C,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;QAC1C,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,KAAe,CAAC,KAAK,KAAK,CAAC;QAExF,IAAI,GAAG,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAE,CAAC;QAEtD,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEtE,MAAM,UAAU,GAAG,aAAa,CAC9B,MAAM,CAAC,IAAI,CAAC,EACZ,mBAAmB,CAAC,UAAU,CAAC,wBAAwB,EAAE,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EACrF,QAAQ,CAAC;YACP,SAAS,EAAE,UAAU,CAAC,KAAK;YAC3B,QAAQ,EAAE,oBAAoB;YAC9B,UAAU;YACV,aAAa,EAAE,IAAI;SACpB,CAAC,CACH,CAAC;QAEF,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {DecoratorParameters, Metadata, StoreMerge, useDecorators, useMethodDecorators} from \"@tsed/core\";\nimport {ParamTypes, UseParam} from \"@tsed/platform-params\";\nimport {InFile} from \"@tsed/schema\";\nimport {PlatformMulterFile} from \"../../config/interfaces/PlatformMulterSettings\";\nimport {MulterInputOptions, PlatformMulterMiddleware} from \"../../middlewares/PlatformMulterMiddleware\";\n\nfunction mapOptions(name: string, maxCount: number | undefined): MulterInputOptions {\n return {\n fields: [\n {\n name,\n maxCount\n }\n ]\n };\n}\n\n/**\n * Define a parameter as Multipart file.\n *\n * ```typescript\n * import {Controller, Post} from \"@tsed/common\";\n * import {MulterOptions, MultipartFile} from \"@tsed/common\";\n * import {Multer} from \"@types/multer\";\n *\n * type MulterFile = Express.Multer.File;\n *\n * @Controller('/')\n * class MyCtrl {\n * @Post('/file')\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile) {\n *\n * }\n *\n * @Post('/file')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile) {\n *\n * }\n *\n * @Post('/file2')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile, @MultipartFile(\"file2\") file2: MulterFile) {\n *\n * }\n *\n * @Post('/files')\n * private uploadFile(@MultipartFile(\"file1\") files: MulterFile[]) {\n *\n * }\n * }\n * ```\n *\n * > See the tutorial on the [multer configuration](/tutorials/multer.md).\n *\n * @param name\n * @param maxCount\n * @returns Function\n * @decorator\n * @input\n */\nexport function MultipartFile(name: string, maxCount?: number): ParameterDecorator {\n return (...args: DecoratorParameters): void => {\n const [target, propertyKey, index] = args;\n const multiple = Metadata.getParamTypes(target, propertyKey)[index as number] === Array;\n\n name = (typeof name === \"object\" ? undefined : name)!;\n\n const expression = [name, !multiple && \"0\"].filter(Boolean).join(\".\");\n\n const decorators = useDecorators(\n InFile(name),\n useMethodDecorators(StoreMerge(PlatformMulterMiddleware, mapOptions(name, maxCount))),\n UseParam({\n paramType: ParamTypes.FILES,\n dataPath: \"$ctx.request.files\",\n expression,\n useValidation: true\n })\n );\n\n decorators(...args);\n };\n}\n\nexport type MultipartFile = PlatformMulterFile;\n"]}
@@ -1,5 +1,5 @@
1
1
  import { Provider, ProviderType } from "@tsed/di";
2
- import { ROUTER_OPTIONS } from "../constants/routerOptions";
2
+ import { ROUTER_OPTIONS } from "../constants/routerOptions.js";
3
3
  let AUTO_INC = 0;
4
4
  export class ControllerProvider extends Provider {
5
5
  constructor(provide, options = {}) {
@@ -1,67 +1,2 @@
1
- import { __decorate } from "tslib";
2
- import { DecoratorTypes, deepMerge, descriptorOf, nameOf, prototypeOf, Store } from "@tsed/core";
3
- import { JsonEntityComponent, JsonEntityStore, JsonMethodStore } from "@tsed/schema";
4
- /**
5
- * EndpointMetadata contains metadata about a controller and his method.
6
- * Each annotation (@Get, @Body...) attached to a method are stored in a endpoint.
7
- * EndpointMetadata convert this metadata to an array which contain arguments to call an Express method.
8
- *
9
- * Example :
10
- *
11
- * @Controller("/my-path")
12
- * provide MyClass {
13
- *
14
- * @Get("/")
15
- * @Authenticated()
16
- * public myMethod(){}
17
- * }
18
- *
19
- */
20
- let EndpointMetadata = class EndpointMetadata extends JsonMethodStore {
21
- get targetName() {
22
- return nameOf(this.token);
23
- }
24
- get params() {
25
- return this.parameters;
26
- }
27
- get view() {
28
- return this.store.get("view");
29
- }
30
- set view(view) {
31
- this.store.set("view", view);
32
- }
33
- get acceptMimes() {
34
- return this.store.get("acceptMimes", []);
35
- }
36
- set acceptMimes(mimes) {
37
- this.store.set("acceptMimes", mimes);
38
- }
39
- /**
40
- * Get an endpoint.
41
- * @param target
42
- * @param propertyKey
43
- * @param descriptor
44
- */
45
- static get(target, propertyKey, descriptor) {
46
- descriptor = descriptor || descriptorOf(prototypeOf(target), propertyKey);
47
- return JsonEntityStore.from(prototypeOf(target), propertyKey, descriptor);
48
- }
49
- addOperationPath(method, path, options = {}) {
50
- return this.operation.addOperationPath(method, path, options);
51
- }
52
- /**
53
- * Find the a value at the controller level. Let this value be extended or overridden by the endpoint itself.
54
- *
55
- * @param key
56
- * @returns {any}
57
- */
58
- get(key) {
59
- const ctrlValue = Store.from(this.target).get(key);
60
- return deepMerge(ctrlValue, this.store.get(key));
61
- }
62
- };
63
- EndpointMetadata = __decorate([
64
- JsonEntityComponent(DecoratorTypes.METHOD)
65
- ], EndpointMetadata);
66
- export { EndpointMetadata };
1
+ export { EndpointMetadata } from "@tsed/schema";
67
2
  //# sourceMappingURL=EndpointMetadata.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EndpointMetadata.js","sourceRoot":"","sources":["../../../src/domain/EndpointMetadata.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAO,MAAM,YAAY,CAAC;AAErG,OAAO,EAAC,mBAAmB,EAAE,eAAe,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AAYnF;;;;;;;;;;;;;;;GAeG;AAEH,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,eAAe;IACnD,IAAI,UAAU;QACZ,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,C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GAC9B,gBAAgB,CAoD5B;SApDY,gBAAgB","sourcesContent":["import {DecoratorTypes, deepMerge, descriptorOf, nameOf, prototypeOf, Store, Type} from \"@tsed/core\";\nimport {ParamMetadata} from \"@tsed/platform-params\";\nimport {JsonEntityComponent, JsonEntityStore, JsonMethodStore} from \"@tsed/schema\";\n\nexport interface EndpointViewOptions {\n path: string;\n options: any;\n}\n\nexport interface EndpointRedirectOptions {\n status: number | undefined;\n url: string;\n}\n\n/**\n * EndpointMetadata contains metadata about a controller and his method.\n * Each annotation (@Get, @Body...) attached to a method are stored in a endpoint.\n * EndpointMetadata convert this metadata to an array which contain arguments to call an Express method.\n *\n * Example :\n *\n * @Controller(\"/my-path\")\n * provide MyClass {\n *\n * @Get(\"/\")\n * @Authenticated()\n * public myMethod(){}\n * }\n *\n */\n@JsonEntityComponent(DecoratorTypes.METHOD)\nexport class EndpointMetadata extends JsonMethodStore {\n get targetName(): string {\n return nameOf(this.token);\n }\n\n get params(): ParamMetadata[] {\n return this.parameters as ParamMetadata[];\n }\n\n get view(): EndpointViewOptions {\n return this.store.get(\"view\") as EndpointViewOptions;\n }\n\n set view(view: EndpointViewOptions) {\n this.store.set(\"view\", view);\n }\n\n get acceptMimes(): string[] {\n return this.store.get<string[]>(\"acceptMimes\", []);\n }\n\n set acceptMimes(mimes: string[]) {\n this.store.set(\"acceptMimes\", mimes);\n }\n\n /**\n * Get an endpoint.\n * @param target\n * @param propertyKey\n * @param descriptor\n */\n static get(target: Type<any>, propertyKey: string | symbol, descriptor?: PropertyDescriptor): EndpointMetadata {\n descriptor = descriptor || descriptorOf(prototypeOf(target), propertyKey);\n\n return JsonEntityStore.from<EndpointMetadata>(prototypeOf(target), propertyKey, descriptor);\n }\n\n addOperationPath(method: string, path: string | RegExp, options: any = {}) {\n return this.operation.addOperationPath(method, path, options);\n }\n\n /**\n * Find the a value at the controller level. Let this value be extended or overridden by the endpoint itself.\n *\n * @param key\n * @returns {any}\n */\n get<T = any>(key: any): T {\n const ctrlValue = Store.from(this.target).get(key);\n\n return deepMerge<T>(ctrlValue, this.store.get(key));\n }\n}\n"]}
1
+ {"version":3,"file":"EndpointMetadata.js","sourceRoot":"","sources":["../../../src/domain/EndpointMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC","sourcesContent":["export {EndpointMetadata} from \"@tsed/schema\";\n"]}
@@ -2,7 +2,7 @@ import { nameOf } from "@tsed/core";
2
2
  import { ProviderScope } from "@tsed/di";
3
3
  import { ParamTypes } from "@tsed/platform-params";
4
4
  import { JsonParameterStore } from "@tsed/schema";
5
- import { HandlerType } from "../interfaces/HandlerType";
5
+ import { HandlerType } from "../interfaces/HandlerType.js";
6
6
  export class HandlerMetadata {
7
7
  constructor(options) {
8
8
  this.injectable = false;
@@ -1,7 +1,7 @@
1
1
  import { DIContext } from "@tsed/di";
2
- import { PlatformApplication } from "../services/PlatformApplication";
3
- import { PlatformRequest } from "../services/PlatformRequest";
4
- import { PlatformResponse } from "../services/PlatformResponse";
2
+ import { PlatformApplication } from "../services/PlatformApplication.js";
3
+ import { PlatformRequest } from "../services/PlatformRequest.js";
4
+ import { PlatformResponse } from "../services/PlatformResponse.js";
5
5
  export class PlatformContext extends DIContext {
6
6
  constructor({ event, endpoint, ignoreUrlPatterns = [], ResponseKlass = PlatformResponse, RequestKlass = PlatformRequest, ...options }) {
7
7
  super({
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformContext.js","sourceRoot":"","sources":["../../../src/domain/PlatformContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAmB,MAAM,UAAU,CAAC;AAGrE,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAiB9D,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAoB5C,YAAY,EACV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C;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAO,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAS,CAAC;IAClC,CAAC;CACF","sourcesContent":["import {ContextMethods, DIContext, DIContextOptions} from \"@tsed/di\";\nimport {IncomingMessage, ServerResponse} from \"http\";\nimport {EndpointMetadata} from \"./EndpointMetadata\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\n\ndeclare global {\n namespace TsED {\n export interface Context extends PlatformContext {}\n }\n}\n\nexport interface PlatformContextOptions extends DIContextOptions {\n event: {\n response?: ServerResponse;\n request?: IncomingMessage;\n };\n ignoreUrlPatterns?: any[];\n endpoint?: EndpointMetadata;\n}\n\nexport class PlatformContext extends DIContext implements ContextMethods {\n /**\n * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.\n */\n public endpoint: EndpointMetadata;\n /**\n * The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.\n */\n public data: any;\n /**\n * The current @@PlatformResponse@@.\n */\n public response: PlatformResponse;\n /**\n * The current @@PlatformRequest@@.\n */\n public request: PlatformRequest;\n\n private ignoreUrlPatterns: RegExp[] = [];\n\n constructor({\n event,\n endpoint,\n ignoreUrlPatterns = [],\n ResponseKlass = PlatformResponse,\n RequestKlass = PlatformRequest,\n ...options\n }: PlatformContextOptions) {\n super({\n ...options,\n ignoreLog: () => {\n return this.ignoreUrlPatterns.find((reg) => !!this.url.match(reg));\n }\n });\n\n endpoint && (this.endpoint = endpoint);\n\n this.ignoreUrlPatterns = ignoreUrlPatterns.map((pattern: string | RegExp) =>\n typeof pattern === \"string\" ? new RegExp(pattern, \"gi\") : pattern\n );\n\n this.response = new ResponseKlass(event, this);\n this.request = new RequestKlass(event, this);\n\n this.response.request = this.request;\n this.request.response = this.response;\n\n this.request.request.$ctx = this;\n this.request.request.id = this.id;\n this.logger.url = this.url;\n\n this.container.set(PlatformResponse, this.response);\n this.container.set(PlatformRequest, this.request);\n this.container.set(PlatformContext, this);\n\n this.response.setHeader(\"x-request-id\", this.id);\n }\n\n get url() {\n return this.request.url;\n }\n\n get app() {\n return this.injector.get<PlatformApplication>(PlatformApplication)!;\n }\n\n async destroy() {\n await super.destroy();\n\n delete this.request?.request?.$ctx;\n\n this.response.destroy();\n this.request.destroy();\n\n // @ts-ignore\n delete this.endpoint;\n // @ts-ignore\n delete this.response;\n // @ts-ignore\n delete this.request;\n }\n\n isDone() {\n if (!this.request || !this.response) {\n return true;\n }\n\n if (this.request?.isAborted()) {\n return true;\n }\n\n return this.response?.isDone();\n }\n\n /**\n * Return the framework request instance (Express, Koa, etc...)\n */\n getRequest<Req = any>(): Req {\n return this.request.getRequest<Req>();\n }\n\n /**\n * Return the framework response instance (Express, Koa, etc...)\n */\n getResponse<Res = any>(): Res {\n return this.response.getResponse<Res>();\n }\n\n /**\n * Get Node.js request\n */\n getReq(): IncomingMessage {\n return this.request.getReq();\n }\n\n /**\n * Get Node.js response\n */\n getRes(): ServerResponse {\n return this.response.getRes();\n }\n\n /**\n * Return the original application instance.\n */\n getApp<T = any>(): T {\n return this.app.getApp() as any;\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformContext.js","sourceRoot":"","sources":["../../../src/domain/PlatformContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAmB,MAAM,UAAU,CAAC;AAGrE,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B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AAE,MAAM,EAAE,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAO,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAO,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAS,CAAC;IAClC,CAAC;CACF","sourcesContent":["import {ContextMethods, DIContext, DIContextOptions} from \"@tsed/di\";\nimport {IncomingMessage, ServerResponse} from \"http\";\nimport {EndpointMetadata} from \"@tsed/schema\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\n\ndeclare global {\n namespace TsED {\n export interface Context extends PlatformContext {}\n }\n}\n\nexport interface PlatformContextOptions extends DIContextOptions {\n event: {\n response?: ServerResponse;\n request?: IncomingMessage;\n };\n ignoreUrlPatterns?: any[];\n endpoint?: EndpointMetadata;\n}\n\nexport class PlatformContext extends DIContext implements ContextMethods {\n /**\n * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.\n */\n public endpoint: EndpointMetadata;\n /**\n * The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.\n */\n public data: any;\n /**\n * The current @@PlatformResponse@@.\n */\n public response: PlatformResponse;\n /**\n * The current @@PlatformRequest@@.\n */\n public request: PlatformRequest;\n\n private ignoreUrlPatterns: RegExp[] = [];\n\n constructor({\n event,\n endpoint,\n ignoreUrlPatterns = [],\n ResponseKlass = PlatformResponse,\n RequestKlass = PlatformRequest,\n ...options\n }: PlatformContextOptions) {\n super({\n ...options,\n ignoreLog: () => {\n return this.ignoreUrlPatterns.find((reg) => !!this.url.match(reg));\n }\n });\n\n endpoint && (this.endpoint = endpoint);\n\n this.ignoreUrlPatterns = ignoreUrlPatterns.map((pattern: string | RegExp) =>\n typeof pattern === \"string\" ? new RegExp(pattern, \"gi\") : pattern\n );\n\n this.response = new ResponseKlass(event, this);\n this.request = new RequestKlass(event, this);\n\n this.response.request = this.request;\n this.request.response = this.response;\n\n this.request.request.$ctx = this;\n this.request.request.id = this.id;\n this.logger.url = this.url;\n\n this.container.set(PlatformResponse, this.response);\n this.container.set(PlatformRequest, this.request);\n this.container.set(PlatformContext, this);\n\n this.response.setHeader(\"x-request-id\", this.id);\n }\n\n get url() {\n return this.request.url;\n }\n\n get app() {\n return this.injector.get<PlatformApplication>(PlatformApplication)!;\n }\n\n async destroy() {\n await super.destroy();\n\n delete this.request?.request?.$ctx;\n\n this.response.destroy();\n this.request.destroy();\n\n // @ts-ignore\n delete this.endpoint;\n // @ts-ignore\n delete this.response;\n // @ts-ignore\n delete this.request;\n }\n\n isDone() {\n if (!this.request || !this.response) {\n return true;\n }\n\n if (this.request?.isAborted()) {\n return true;\n }\n\n return this.response?.isDone();\n }\n\n /**\n * Return the framework request instance (Express, Koa, etc...)\n */\n getRequest<Req = any>(): Req {\n return this.request.getRequest<Req>();\n }\n\n /**\n * Return the framework response instance (Express, Koa, etc...)\n */\n getResponse<Res = any>(): Res {\n return this.response.getResponse<Res>();\n }\n\n /**\n * Get Node.js request\n */\n getReq(): IncomingMessage {\n return this.request.getReq();\n }\n\n /**\n * Get Node.js response\n */\n getRes(): ServerResponse {\n return this.response.getRes();\n }\n\n /**\n * Return the original application instance.\n */\n getApp<T = any>(): T {\n return this.app.getApp() as any;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformRouteDetails.js","sourceRoot":"","sources":["../../../src/domain/PlatformRouteDetails.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAC,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAWhD,MAAM,OAAO,oBAAqB,SAAQ,kBAAoC;IAI5E,YAAY,UAAyC,EAAE;QACrD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,KAAoB,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,UAAU,CAAC,QAAQ,CAAC,CAAC;IACpH,CAAC;IAED,MAAM;QACJ,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;CACF","sourcesContent":["import {ParamMetadata, ParamTypes} from \"@tsed/platform-params\";\nimport {JsonOperationRoute} from \"@tsed/schema\";\nimport {EndpointMetadata} from \"./EndpointMetadata\";\nimport {ControllerProvider} from \"./ControllerProvider\";\n\nexport interface PlatformRouterDetailsOptions {\n provider: ControllerProvider;\n endpoint: EndpointMetadata;\n method: string;\n url: string;\n}\n\nexport class PlatformRouteDetails extends JsonOperationRoute<EndpointMetadata> {\n readonly rawBody: boolean;\n readonly provider: ControllerProvider;\n\n constructor(options: Partial<PlatformRouteDetails> = {}) {\n super(options);\n this.rawBody = !!this.endpoint.parameters.find((param: ParamMetadata) => param.paramType === ParamTypes.RAW_BODY);\n }\n\n toJSON() {\n return {\n method: this.method,\n name: this.name,\n url: this.url,\n className: this.className,\n methodClassName: this.methodClassName,\n parameters: this.parameters,\n rawBody: this.rawBody\n };\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformRouteDetails.js","sourceRoot":"","sources":["../../../src/domain/PlatformRouteDetails.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAmB,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAUlE,MAAM,OAAO,oBAAqB,SAAQ,kBAAoC;IAI5E,YAAY,UAAyC,EAAE;QACrD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,UAAU,CAAC,QAAQ,CAAC,CAAC;IACrG,CAAC;IAED,MAAM;QACJ,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;CACF","sourcesContent":["import {ParamTypes} from \"@tsed/platform-params\";\nimport {EndpointMetadata, JsonOperationRoute} from \"@tsed/schema\";\nimport {ControllerProvider} from \"./ControllerProvider\";\n\nexport interface PlatformRouterDetailsOptions {\n provider: ControllerProvider;\n endpoint: EndpointMetadata;\n method: string;\n url: string;\n}\n\nexport class PlatformRouteDetails extends JsonOperationRoute<EndpointMetadata> {\n readonly rawBody: boolean;\n readonly provider: ControllerProvider;\n\n constructor(options: Partial<PlatformRouteDetails> = {}) {\n super(options);\n this.rawBody = !!this.endpoint.parameters.find((param) => param.paramType === ParamTypes.RAW_BODY);\n }\n\n toJSON() {\n return {\n method: this.method,\n name: this.name,\n url: this.url,\n className: this.className,\n methodClassName: this.methodClassName,\n parameters: this.parameters,\n rawBody: this.rawBody\n };\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import "@tsed/logger";
2
+ import "@tsed/logger-file";
3
+ export * from "@tsed/di";
4
+ export * from "@tsed/platform-params";
5
+ export * from "@tsed/platform-exceptions";
6
+ export * from "@tsed/platform-response-filter";
7
+ export * from "@tsed/platform-cache";
8
+ export * from "@tsed/platform-middlewares";
9
+ export * from "@tsed/components-scan";
10
+ export * from "@tsed/platform-log-middleware";
11
+ export { $log, Logger } from "@tsed/logger";
12
+ export { AcceptMime, Location, Redirect, View, Get, Post, Put, Patch, Delete, Head, Options, All } from "@tsed/schema";
13
+ //# sourceMappingURL=exports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AACtB,OAAO,mBAAmB,CAAC;AAE3B,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAE9C,OAAO,EAAC,IAAI,EAAE,MAAM,EAAC,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAC,MAAM,cAAc,CAAC","sourcesContent":["import \"@tsed/logger\";\nimport \"@tsed/logger-file\";\n\nexport * from \"@tsed/di\";\nexport * from \"@tsed/platform-params\";\nexport * from \"@tsed/platform-exceptions\";\nexport * from \"@tsed/platform-response-filter\";\nexport * from \"@tsed/platform-cache\";\nexport * from \"@tsed/platform-middlewares\";\nexport * from \"@tsed/components-scan\";\nexport * from \"@tsed/platform-log-middleware\";\n\nexport {$log, Logger} from \"@tsed/logger\";\n\nexport {AcceptMime, Location, Redirect, View, Get, Post, Put, Patch, Delete, Head, Options, All} from \"@tsed/schema\";\n"]}
package/lib/esm/index.js CHANGED
@@ -1,28 +1,67 @@
1
- import "@tsed/logger";
2
- export * from "@tsed/di";
3
- export * from "@tsed/platform-params";
4
- export * from "@tsed/platform-exceptions";
5
- export * from "@tsed/platform-response-filter";
6
- export * from "@tsed/platform-cache";
7
- export * from "@tsed/platform-middlewares";
8
- export * from "@tsed/components-scan";
9
- export * from "@tsed/platform-log-middleware";
10
- export { $log, Logger } from "@tsed/logger";
11
- export * from "./config";
12
- // builder
13
- export * from "./builder/PlatformBuilder";
14
- export * from "./builder/PlatformControllerBuilder";
15
- // decorators
16
- export * from "./decorators";
17
- // interfaces
18
- export * from "./constants/routerOptions";
19
- export * from "./interfaces";
20
- // middlewares
21
- export * from "./middlewares";
22
- // domain
23
- export * from "./domain";
24
- // providers
25
- export * from "./services";
26
- // utils
27
- export * from "./utils";
1
+ /**
2
+ * @file Automatically generated by barrelsby.
3
+ */
4
+ export * from "./exports.js";
5
+ export * from "./builder/PlatformBuilder.js";
6
+ export * from "./builder/PlatformControllerBuilder.js";
7
+ export * from "./config/interfaces/ConverterSettings.js";
8
+ export * from "./config/interfaces/EndpointDirectoriesSettings.js";
9
+ export * from "./config/interfaces/PlatformLoggerSettings.js";
10
+ export * from "./config/interfaces/PlatformMulterSettings.js";
11
+ export * from "./config/interfaces/PlatformStaticsSettings.js";
12
+ export * from "./config/services/PlatformConfiguration.js";
13
+ export * from "./constants/routerOptions.js";
14
+ export * from "./decorators/multer/multerFileSize.js";
15
+ export * from "./decorators/multer/multerOptions.js";
16
+ export * from "./decorators/multer/multipartFile.js";
17
+ export * from "./decorators/params/error.js";
18
+ export * from "./decorators/params/next.js";
19
+ export * from "./decorators/params/request.js";
20
+ export * from "./decorators/params/response.js";
21
+ export * from "./domain/AnyToPromiseWithCtx.js";
22
+ export * from "./domain/ControllerProvider.js";
23
+ export * from "./domain/EndpointMetadata.js";
24
+ export * from "./domain/HandlerMetadata.js";
25
+ export * from "./domain/PlatformContext.js";
26
+ export * from "./domain/PlatformRouteDetails.js";
27
+ export * from "./interfaces/AfterInit.js";
28
+ export * from "./interfaces/AfterListen.js";
29
+ export * from "./interfaces/AfterRoutesInit.js";
30
+ export * from "./interfaces/BeforeInit.js";
31
+ export * from "./interfaces/BeforeListen.js";
32
+ export * from "./interfaces/BeforeRoutesInit.js";
33
+ export * from "./interfaces/HandlerType.js";
34
+ export * from "./interfaces/IncomingEvent.js";
35
+ export * from "./interfaces/OnReady.js";
36
+ export * from "./interfaces/OnRequest.js";
37
+ export * from "./interfaces/OnResponse.js";
38
+ export * from "./interfaces/OnRoutesInit.js";
39
+ export * from "./interfaces/PlatformRouteOptions.js";
40
+ export * from "./interfaces/ResponseErrorObject.js";
41
+ export * from "./interfaces/Route.js";
42
+ export * from "./middlewares/PlatformAcceptMimesMiddleware.js";
43
+ export * from "./middlewares/PlatformMulterMiddleware.js";
44
+ export * from "./middlewares/bindEndpointMiddleware.js";
45
+ export * from "./services/FakeAdapter.js";
46
+ export * from "./services/Platform.js";
47
+ export * from "./services/PlatformAdapter.js";
48
+ export * from "./services/PlatformApplication.js";
49
+ export * from "./services/PlatformHandler.js";
50
+ export * from "./services/PlatformMiddlewaresChain.js";
51
+ export * from "./services/PlatformRequest.js";
52
+ export * from "./services/PlatformResponse.js";
53
+ export * from "./services/PlatformRouter.js";
54
+ export * from "./services/PlatformTest.js";
55
+ export * from "./utils/createContext.js";
56
+ export * from "./utils/createHandlerMetadata.js";
57
+ export * from "./utils/createHttpServer.js";
58
+ export * from "./utils/createHttpsServer.js";
59
+ export * from "./utils/createInjector.js";
60
+ export * from "./utils/getStaticsOptions.js";
61
+ export * from "./utils/importProviders.js";
62
+ export * from "./utils/listenServer.js";
63
+ export * from "./utils/mapReturnedResponse.js";
64
+ export * from "./utils/printRoutes.js";
65
+ export * from "./utils/setResponseHeaders.js";
66
+ export * from "./utils/useCtxHandler.js";
28
67
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAE9C,OAAO,EAAC,IAAI,EAAE,MAAM,EAAC,MAAM,cAAc,CAAC;AAE1C,cAAc,UAAU,CAAC;AAEzB,UAAU;AACV,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qCAAqC,CAAC;AAEpD,aAAa;AACb,cAAc,cAAc,CAAC;AAE7B,aAAa;AACb,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC;AAE7B,cAAc;AACd,cAAc,eAAe,CAAC;AAE9B,SAAS;AACT,cAAc,UAAU,CAAC;AAEzB,YAAY;AACZ,cAAc,YAAY,CAAC;AAE3B,QAAQ;AACR,cAAc,SAAS,CAAC","sourcesContent":["import \"@tsed/logger\";\n\nexport * from \"@tsed/di\";\nexport * from \"@tsed/platform-params\";\nexport * from \"@tsed/platform-exceptions\";\nexport * from \"@tsed/platform-response-filter\";\nexport * from \"@tsed/platform-cache\";\nexport * from \"@tsed/platform-middlewares\";\nexport * from \"@tsed/components-scan\";\nexport * from \"@tsed/platform-log-middleware\";\n\nexport {$log, Logger} from \"@tsed/logger\";\n\nexport * from \"./config\";\n\n// builder\nexport * from \"./builder/PlatformBuilder\";\nexport * from \"./builder/PlatformControllerBuilder\";\n\n// decorators\nexport * from \"./decorators\";\n\n// interfaces\nexport * from \"./constants/routerOptions\";\nexport * from \"./interfaces\";\n\n// middlewares\nexport * from \"./middlewares\";\n\n// domain\nexport * from \"./domain\";\n\n// providers\nexport * from \"./services\";\n\n// utils\nexport * from \"./utils\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qCAAqC,CAAC;AACpD,cAAc,uCAAuC,CAAC;AACtD,cAAc,iDAAiD,CAAC;AAChE,cAAc,4CAA4C,CAAC;AAC3D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,yCAAyC,CAAC;AACxD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC;AACnC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,wCAAwC,CAAC;AACvD,cAAc,sCAAsC,CAAC;AACrD,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qCAAqC,CAAC;AACpD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./exports\";\nexport * from \"./builder/PlatformBuilder\";\nexport * from \"./builder/PlatformControllerBuilder\";\nexport * from \"./config/interfaces/ConverterSettings\";\nexport * from \"./config/interfaces/EndpointDirectoriesSettings\";\nexport * from \"./config/interfaces/PlatformLoggerSettings\";\nexport * from \"./config/interfaces/PlatformMulterSettings\";\nexport * from \"./config/interfaces/PlatformStaticsSettings\";\nexport * from \"./config/services/PlatformConfiguration\";\nexport * from \"./constants/routerOptions\";\nexport * from \"./decorators/multer/multerFileSize\";\nexport * from \"./decorators/multer/multerOptions\";\nexport * from \"./decorators/multer/multipartFile\";\nexport * from \"./decorators/params/error\";\nexport * from \"./decorators/params/next\";\nexport * from \"./decorators/params/request\";\nexport * from \"./decorators/params/response\";\nexport * from \"./domain/AnyToPromiseWithCtx\";\nexport * from \"./domain/ControllerProvider\";\nexport * from \"./domain/EndpointMetadata\";\nexport * from \"./domain/HandlerMetadata\";\nexport * from \"./domain/PlatformContext\";\nexport * from \"./domain/PlatformRouteDetails\";\nexport * from \"./interfaces/AfterInit\";\nexport * from \"./interfaces/AfterListen\";\nexport * from \"./interfaces/AfterRoutesInit\";\nexport * from \"./interfaces/BeforeInit\";\nexport * from \"./interfaces/BeforeListen\";\nexport * from \"./interfaces/BeforeRoutesInit\";\nexport * from \"./interfaces/HandlerType\";\nexport * from \"./interfaces/IncomingEvent\";\nexport * from \"./interfaces/OnReady\";\nexport * from \"./interfaces/OnRequest\";\nexport * from \"./interfaces/OnResponse\";\nexport * from \"./interfaces/OnRoutesInit\";\nexport * from \"./interfaces/PlatformRouteOptions\";\nexport * from \"./interfaces/ResponseErrorObject\";\nexport * from \"./interfaces/Route\";\nexport * from \"./middlewares/PlatformAcceptMimesMiddleware\";\nexport * from \"./middlewares/PlatformMulterMiddleware\";\nexport * from \"./middlewares/bindEndpointMiddleware\";\nexport * from \"./services/FakeAdapter\";\nexport * from \"./services/Platform\";\nexport * from \"./services/PlatformAdapter\";\nexport * from \"./services/PlatformApplication\";\nexport * from \"./services/PlatformHandler\";\nexport * from \"./services/PlatformMiddlewaresChain\";\nexport * from \"./services/PlatformRequest\";\nexport * from \"./services/PlatformResponse\";\nexport * from \"./services/PlatformRouter\";\nexport * from \"./services/PlatformTest\";\nexport * from \"./utils/createContext\";\nexport * from \"./utils/createHandlerMetadata\";\nexport * from \"./utils/createHttpServer\";\nexport * from \"./utils/createHttpsServer\";\nexport * from \"./utils/createInjector\";\nexport * from \"./utils/getStaticsOptions\";\nexport * from \"./utils/importProviders\";\nexport * from \"./utils/listenServer\";\nexport * from \"./utils/mapReturnedResponse\";\nexport * from \"./utils/printRoutes\";\nexport * from \"./utils/setResponseHeaders\";\nexport * from \"./utils/useCtxHandler\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformRouteOptions.js","sourceRoot":"","sources":["../../../src/interfaces/PlatformRouteOptions.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {PathType} from \"./PathType\";\n\n/**\n * @ignore\n */\nexport interface PlatformRouteOptions {\n token?: Type<any>;\n path?: PathType | undefined;\n method?: string;\n isFinal?: boolean;\n handlers: any[];\n}\n\n/**\n * @ignore\n */\nexport type PlatformRouteWithoutHandlers = Partial<Omit<PlatformRouteOptions, \"handlers\">>;\n"]}
1
+ {"version":3,"file":"PlatformRouteOptions.js","sourceRoot":"","sources":["../../../src/interfaces/PlatformRouteOptions.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {PathType} from \"@tsed/di\";\n\n/**\n * @ignore\n */\nexport interface PlatformRouteOptions {\n token?: Type<any>;\n path?: PathType | undefined;\n method?: string;\n isFinal?: boolean;\n handlers: any[];\n}\n\n/**\n * @ignore\n */\nexport type PlatformRouteWithoutHandlers = Partial<Omit<PlatformRouteOptions, \"handlers\">>;\n"]}
@@ -1,10 +1,17 @@
1
1
  var PlatformMulterMiddleware_1;
2
2
  import { __decorate, __metadata, __param } from "tslib";
3
- import { Constant, Inject } from "@tsed/di";
4
- import { Exception } from "@tsed/exceptions";
3
+ import { Inject, Value } from "@tsed/di";
4
+ import { BadRequest } from "@tsed/exceptions";
5
5
  import { Middleware } from "@tsed/platform-middlewares";
6
6
  import { Context } from "@tsed/platform-params";
7
- import { PlatformApplication } from "../services/PlatformApplication";
7
+ import { PlatformApplication } from "../services/PlatformApplication.js";
8
+ export class MulterException extends BadRequest {
9
+ constructor(er) {
10
+ super(er.message);
11
+ this.origin = er;
12
+ this.name = er.code;
13
+ }
14
+ }
8
15
  /**
9
16
  * @middleware
10
17
  */
@@ -24,7 +31,10 @@ let PlatformMulterMiddleware = PlatformMulterMiddleware_1 = class PlatformMulter
24
31
  return await middleware(ctx.getRequest(), ctx.getResponse());
25
32
  }
26
33
  catch (er) {
27
- throw er.code ? new Exception(er.code, `${er.message} ${er.field || ""}`.trim()) : er;
34
+ if (er.code) {
35
+ throw new MulterException(er);
36
+ }
37
+ throw er;
28
38
  }
29
39
  }
30
40
  getFields(conf) {
@@ -32,7 +42,8 @@ let PlatformMulterMiddleware = PlatformMulterMiddleware_1 = class PlatformMulter
32
42
  }
33
43
  };
34
44
  __decorate([
35
- Constant("multer", {}),
45
+ Value("multer", {}) // NOTE: don't use constant to getting multer configuration. See issue #1840
46
+ ,
36
47
  __metadata("design:type", Object)
37
48
  ], PlatformMulterMiddleware.prototype, "settings", void 0);
38
49
  __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformMulterMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PlatformMulterMiddleware.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,UAAU,EAAoB,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAE9C,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AAMpE;;GAEG;AAEH,IAAa,wBAAwB,gCAArC,MAAa,wBAAwB;IAOnC,KAAK,CAAC,GAAG,CAAY,GAAY;QAC/B,IAAI;YACF,MAAM,EAAC,MAAM,EAAE,OAAO,GAAG,EAAE,EAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,0BAAwB,CAAC,CAAC;YAC1E,MAAM,QAAQ,GAA2B;gBACvC,GAAG,IAAI,CAAC,QAAQ;gBAChB,GAAG,OAAO;aACX,CAAC;YAEF,0BAA0B;YAC1B,IAAI,QAAQ,CAAC,OAAO,EAAE;gBACpB,OAAO,QAAQ,CAAC,IAAI,CAAC;aACtB;YAED,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAC,MAAM,EAAC,CAAC,CAAC,CAAC;YAE9E,OAAO,MAAM,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;SAC9D;QAAC,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,IAAI,EAAE,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SACvF;IACH,CAAC;IAES,SAAS,CAAC,IAAwB;QAC1C,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,EAAE,EAAE,CAAC,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAC,CAAC;IACnE,CAAC;CACF,CAAA;AA7BC;IADC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC;;0DACU;AAGjC;IADC,MAAM,EAAE;8BACJ,mBAAmB;qDAAC;AAEzB;IAAW,WAAA,OAAO,EAAE,CAAA;;;;mDAmBnB;AA1BU,wBAAwB;IADpC,UAAU,EAAE;GACA,wBAAwB,CA+BpC;SA/BY,wBAAwB","sourcesContent":["import {Constant, Inject} from \"@tsed/di\";\nimport {Exception} from \"@tsed/exceptions\";\nimport {Middleware, MiddlewareMethods} from \"@tsed/platform-middlewares\";\nimport {Context} from \"@tsed/platform-params\";\nimport {PlatformMulterField, PlatformMulterSettings} from \"../config\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\n\nexport interface MulterInputOptions {\n fields: PlatformMulterField[];\n}\n\n/**\n * @middleware\n */\n@Middleware()\nexport class PlatformMulterMiddleware implements MiddlewareMethods {\n @Constant(\"multer\", {})\n settings: PlatformMulterSettings;\n\n @Inject()\n app: PlatformApplication;\n\n async use(@Context() ctx: Context) {\n try {\n const {fields, options = {}} = ctx.endpoint.get(PlatformMulterMiddleware);\n const settings: PlatformMulterSettings = {\n ...this.settings,\n ...options\n };\n\n /* istanbul ignore next */\n if (settings.storage) {\n delete settings.dest;\n }\n\n const middleware = this.app.multer(settings).fields(this.getFields({fields}));\n\n return await middleware(ctx.getRequest(), ctx.getResponse());\n } catch (er) {\n throw er.code ? new Exception(er.code, `${er.message} ${er.field || \"\"}`.trim()) : er;\n }\n }\n\n protected getFields(conf: MulterInputOptions) {\n return conf.fields.map(({name, maxCount}) => ({name, maxCount}));\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformMulterMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PlatformMulterMiddleware.ts"],"names":[],"mappings":";;AACA,OAAO,EAAW,MAAM,EAAE,KAAK,EAAC,MAAM,UAAU,CAAC;AACjD,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAC,UAAU,EAAoB,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAE9C,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AAOpE,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAC7C,YAAY,EAAe;QACzB,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC;IACtB,CAAC;CACF;AAED;;GAEG;AAEH,IAAa,wBAAwB,gCAArC,MAAa,wBAAwB;IAOnC,KAAK,CAAC,GAAG,CAAY,GAAY;QAC/B,IAAI;YACF,MAAM,EAAC,MAAM,EAAE,OAAO,GAAG,EAAE,EAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,0BAAwB,CAAC,CAAC;YAC1E,MAAM,QAAQ,GAA2B;gBACvC,GAAG,IAAI,CAAC,QAAQ;gBAChB,GAAG,OAAO;aACX,CAAC;YAEF,0BAA0B;YAC1B,IAAI,QAAQ,CAAC,OAAO,EAAE;gBACpB,OAAO,QAAQ,CAAC,IAAI,CAAC;aACtB;YAED,MAAM,UAAU,GAAQ,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAC,MAAM,EAAC,CAAC,CAAC,CAAC;YAEnF,OAAO,MAAM,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;SAC9D;QAAC,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,CAAC,IAAI,EAAE;gBACX,MAAM,IAAI,eAAe,CAAC,EAAE,CAAC,CAAC;aAC/B;YAED,MAAM,EAAE,CAAC;SACV;IACH,CAAC;IAES,SAAS,CAAC,IAAwB;QAC1C,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,EAAE,EAAE,CAAC,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAC,CAAC;IACnE,CAAC;CACF,CAAA;AAjCC;IADC,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,4EAA4E;;;0DACtD;AAG3C;IADC,MAAM,EAAE;8BACM,mBAAmB;qDAAC;AAEnC;IAAW,WAAA,OAAO,EAAE,CAAA;;;;mDAuBnB;AA9BU,wBAAwB;IADpC,UAAU,EAAE;GACA,wBAAwB,CAmCpC;SAnCY,wBAAwB","sourcesContent":["import type {MulterError} from \"multer\";\nimport {Constant, Inject, Value} from \"@tsed/di\";\nimport {BadRequest} from \"@tsed/exceptions\";\nimport {Middleware, MiddlewareMethods} from \"@tsed/platform-middlewares\";\nimport {Context} from \"@tsed/platform-params\";\nimport {PlatformMulterField, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformConfiguration} from \"../config/services/PlatformConfiguration\";\n\nexport interface MulterInputOptions {\n fields: PlatformMulterField[];\n}\n\nexport class MulterException extends BadRequest {\n constructor(er: MulterError) {\n super(er.message);\n this.origin = er;\n this.name = er.code;\n }\n}\n\n/**\n * @middleware\n */\n@Middleware()\nexport class PlatformMulterMiddleware implements MiddlewareMethods {\n @Value(\"multer\", {}) // NOTE: don't use constant to getting multer configuration. See issue #1840\n protected settings: PlatformMulterSettings;\n\n @Inject()\n protected app: PlatformApplication;\n\n async use(@Context() ctx: Context) {\n try {\n const {fields, options = {}} = ctx.endpoint.get(PlatformMulterMiddleware);\n const settings: PlatformMulterSettings = {\n ...this.settings,\n ...options\n };\n\n /* istanbul ignore next */\n if (settings.storage) {\n delete settings.dest;\n }\n\n const middleware: any = this.app.multer(settings).fields(this.getFields({fields}));\n\n return await middleware(ctx.getRequest(), ctx.getResponse());\n } catch (er) {\n if (er.code) {\n throw new MulterException(er);\n }\n\n throw er;\n }\n }\n\n protected getFields(conf: MulterInputOptions) {\n return conf.fields.map(({name, maxCount}) => ({name, maxCount}));\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"bindEndpointMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/bindEndpointMiddleware.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAA0B;IAC/D,OAAO,CAAC,GAAoB,EAAE,EAAE;QAC9B,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type {EndpointMetadata, PlatformContext} from \"../domain\";\n\n/**\n * @ignore\n */\nexport function bindEndpointMiddleware(endpoint: EndpointMetadata) {\n return (ctx: PlatformContext) => {\n ctx.endpoint = endpoint;\n };\n}\n"]}
1
+ {"version":3,"file":"bindEndpointMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/bindEndpointMiddleware.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAA0B;IAC/D,OAAO,CAAC,GAAoB,EAAE,EAAE;QAC9B,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type {EndpointMetadata} from \"../domain/EndpointMetadata\";\nimport type {PlatformContext} from \"../domain/PlatformContext\";\n\n/**\n * @ignore\n */\nexport function bindEndpointMiddleware(endpoint: EndpointMetadata) {\n return (ctx: PlatformContext) => {\n ctx.endpoint = endpoint;\n };\n}\n"]}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,51 @@
1
+ export class FakeAdapter {
2
+ constructor() {
3
+ this.providers = [];
4
+ }
5
+ static createFakeRawDriver() {
6
+ // istanbul ignore next
7
+ function FakeRawDriver() { }
8
+ // istanbul ignore next
9
+ function use() {
10
+ return this;
11
+ }
12
+ FakeRawDriver.use = use;
13
+ FakeRawDriver.all = use;
14
+ FakeRawDriver.get = use;
15
+ FakeRawDriver.patch = use;
16
+ FakeRawDriver.post = use;
17
+ FakeRawDriver.put = use;
18
+ FakeRawDriver.head = use;
19
+ FakeRawDriver.delete = use;
20
+ FakeRawDriver.options = use;
21
+ return FakeRawDriver;
22
+ }
23
+ app() {
24
+ const app = FakeAdapter.createFakeRawDriver();
25
+ return {
26
+ app,
27
+ callback() {
28
+ return app;
29
+ }
30
+ };
31
+ }
32
+ multipart(options) {
33
+ return {};
34
+ }
35
+ router(routerOptions) {
36
+ const router = FakeAdapter.createFakeRawDriver();
37
+ return {
38
+ router,
39
+ callback() {
40
+ return router;
41
+ }
42
+ };
43
+ }
44
+ statics(endpoint, options) {
45
+ return {};
46
+ }
47
+ bodyParser(type) {
48
+ return () => { };
49
+ }
50
+ }
51
+ //# sourceMappingURL=FakeAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FakeAdapter.js","sourceRoot":"","sources":["../../../src/services/FakeAdapter.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,WA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import {PlatformMulter, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformStaticsOptions} from \"../config/interfaces/PlatformStaticsSettings\";\n\nexport class FakeAdapter implements PlatformAdapter<any, any> {\n providers: ProviderOpts[] = [];\n\n static createFakeRawDriver() {\n // istanbul ignore next\n function FakeRawDriver() {}\n\n // istanbul ignore next\n function use() {\n return this;\n }\n\n FakeRawDriver.use = use;\n FakeRawDriver.all = use;\n FakeRawDriver.get = use;\n FakeRawDriver.patch = use;\n FakeRawDriver.post = use;\n FakeRawDriver.put = use;\n FakeRawDriver.head = use;\n FakeRawDriver.delete = use;\n FakeRawDriver.options = use;\n\n return FakeRawDriver;\n }\n\n app(): {app: any; callback(): any} {\n const app = FakeAdapter.createFakeRawDriver();\n return {\n app,\n callback() {\n return app;\n }\n };\n }\n\n multipart(options: PlatformMulterSettings): PlatformMulter {\n return {} as any;\n }\n\n router(routerOptions: any): {router: any; callback(): any} {\n const router = FakeAdapter.createFakeRawDriver();\n return {\n router,\n callback() {\n return router;\n }\n };\n }\n\n statics(endpoint: string, options: PlatformStaticsOptions): any {\n return {};\n }\n\n bodyParser(type: string): any {\n return () => {};\n }\n}\n"]}
@@ -1,10 +1,10 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
2
  import { Injectable, InjectorService, ProviderScope, ProviderType } from "@tsed/di";
3
- import { concatPath, getOperationsRoutes, JsonEntityStore } from "@tsed/schema";
4
- import { buildRouter, createRouter, getRouter } from "../builder/PlatformControllerBuilder";
5
- import { PlatformRouteDetails } from "../domain";
6
- import { PlatformApplication } from "./PlatformApplication";
7
- import { PlatformMiddlewaresChain } from "./PlatformMiddlewaresChain";
3
+ import { concatPath, getJsonEntityStore, getOperationsRoutes, JsonEntityStore } from "@tsed/schema";
4
+ import { buildRouter, createRouter, getRouter } from "../builder/PlatformControllerBuilder.js";
5
+ import { PlatformRouteDetails } from "../domain/PlatformRouteDetails.js";
6
+ import { PlatformApplication } from "./PlatformApplication.js";
7
+ import { PlatformMiddlewaresChain } from "./PlatformMiddlewaresChain.js";
8
8
  /**
9
9
  * `Platform` is used to provide all routes collected by annotation `@Controller`.
10
10
  *
@@ -35,11 +35,8 @@ let Platform = class Platform {
35
35
  if (!provider || provider.hasParent()) {
36
36
  return;
37
37
  }
38
+ this._controllers.push(...this.getAllControllers(basePath, token));
38
39
  const ctrlPath = concatPath(basePath, JsonEntityStore.from(provider.token).path);
39
- this._controllers.push({
40
- route: ctrlPath,
41
- provider
42
- });
43
40
  this.app.use(ctrlPath, ...[].concat(getRouter(injector, provider).callback()));
44
41
  this._routes = getOperationsRoutes(provider.token, {
45
42
  withChildren: true,
@@ -51,7 +48,7 @@ let Platform = class Platform {
51
48
  ...operationRoute,
52
49
  provider
53
50
  });
54
- return routes.concat(route);
51
+ routes = routes.concat(route);
55
52
  }
56
53
  return routes;
57
54
  }, this._routes);
@@ -64,6 +61,10 @@ let Platform = class Platform {
64
61
  getRoutes() {
65
62
  return this._routes;
66
63
  }
64
+ /**
65
+ * Get all controllers mounted on the application.
66
+ * @returns {RouteController[]}
67
+ */
67
68
  getMountedControllers() {
68
69
  return this._controllers;
69
70
  }
@@ -80,6 +81,26 @@ let Platform = class Platform {
80
81
  createRouter(injector, provider);
81
82
  });
82
83
  }
84
+ /**
85
+ * Get all router controllers from the controller token.
86
+ * @private
87
+ */
88
+ getAllControllers(basePath, token) {
89
+ const store = token.isStore ? token : getJsonEntityStore(token);
90
+ const ctrlPath = concatPath(basePath, JsonEntityStore.from(token).path);
91
+ const children = store.get("childrenControllers", []);
92
+ return children
93
+ .reduce((controllers, token) => {
94
+ const childBasePath = concatPath(basePath, store.path);
95
+ return controllers.concat(this.getAllControllers(childBasePath, token));
96
+ }, [])
97
+ .concat([
98
+ {
99
+ route: ctrlPath,
100
+ provider: this.injector.getProvider(token)
101
+ }
102
+ ]);
103
+ }
83
104
  /**
84
105
  * Create controllers from DI
85
106
  * @private
@@ -1 +1 @@
1
- {"version":3,"file":"Platform.js","sourceR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aAAa;QACnB,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;QAExB,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,QAA4B,EAAE,EAAE;YAClF,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACK,gBAAgB;QACtB,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;QAExB,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,QAA4B,EAAE,EAAE;YAClF,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;gBACzB,OAAO,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;aACxC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AApGY,QAAQ;IAJpB,UAAU,CAAC;QACV,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,OAAO,EAAE,CAAC,wBAAwB,CAAC;KACpC,CAAC;qCAK+B,eAAe,EAAgC,mBAAmB;GAJtF,QAAQ,CAoGpB;SApGY,QAAQ","sourcesContent":["import {Injectable, InjectorService, ProviderScope, ProviderType, TokenProvider} from \"@tsed/di\";\nimport {concatPath, getOperationsRoutes, JsonEntityStore} from \"@tsed/schema\";\nimport {buildRouter, createRouter, getRouter} from \"../builder/PlatformControllerBuilder\";\nimport {ControllerProvider, EndpointMetadata, PlatformRouteDetails} from \"../domain\";\nimport {Route, RouteController} from \"../interfaces/Route\";\nimport {PlatformApplication} from \"./PlatformApplication\";\nimport {PlatformMiddlewaresChain} from \"./PlatformMiddlewaresChain\";\n\n/**\n * `Platform` is used to provide all routes collected by annotation `@Controller`.\n *\n * @platform\n */\n@Injectable({\n scope: ProviderScope.SINGLETON,\n imports: [PlatformMiddlewaresChain]\n})\nexport class Platform {\n private _routes: PlatformRouteDetails[] = [];\n private _controllers: RouteController[] = [];\n\n constructor(readonly injector: InjectorService, readonly platformApplication: PlatformApplication) {\n this.createRouters();\n }\n\n get app() {\n return this.platformApplication;\n }\n\n get routes(): PlatformRouteDetails[] {\n return this._routes;\n }\n\n public addRoutes(routes: Route[]) {\n routes.forEach((routeSettings) => {\n this.addRoute(routeSettings.route, routeSettings.token);\n });\n }\n\n public addRoute(basePath: string, token: TokenProvider) {\n const {injector} = this;\n const provider = injector.getProvider(token) as ControllerProvider;\n\n if (!provider || provider.hasParent()) {\n return;\n }\n\n const ctrlPath = concatPath(basePath, JsonEntityStore.from(provider.token).path);\n\n this._controllers.push({\n route: ctrlPath,\n provider\n });\n\n this.app.use(ctrlPath, ...[].concat(getRouter(injector, provider).callback()));\n\n this._routes = getOperationsRoutes<EndpointMetadata>(provider.token, {\n withChildren: true,\n basePath\n }).reduce((routes, operationRoute) => {\n if (injector.hasProvider(token)) {\n const provider = injector.getProvider(operationRoute.token) as ControllerProvider;\n const route = new PlatformRouteDetails({\n ...operationRoute,\n provider\n });\n\n return routes.concat(route);\n }\n\n return routes;\n }, this._routes);\n\n return this;\n }\n\n /**\n * Get all routes built by TsExpressDecorators and mounted on Express application.\n * @returns {PlatformRouteDetails[]}\n */\n public getRoutes(): PlatformRouteDetails[] {\n return this._routes;\n }\n\n public getMountedControllers(): RouteController[] {\n return this._controllers;\n }\n\n protected $onInit() {\n this.buildControllers();\n }\n\n /**\n * Create routers from the collected controllers.\n * @private\n */\n private createRouters() {\n const {injector} = this;\n\n injector.getProviders(ProviderType.CONTROLLER).map((provider: ControllerProvider) => {\n createRouter(injector, provider);\n });\n }\n\n /**\n * Create controllers from DI\n * @private\n */\n private buildControllers() {\n const {injector} = this;\n\n injector.getProviders(ProviderType.CONTROLLER).map((provider: ControllerProvider) => {\n if (!provider.hasParent()) {\n return buildRouter(injector, provider);\n }\n });\n }\n}\n"]}
1
+ {"version":3,"file":"Platform.js","sourceRoot":"","sources":["../../../src/services/Platform.ts"],"names":[],"mapp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AAI,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;gBACzB,OAAO,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;aACxC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA3HY,QAAQ;IAJpB,UAAU,CAAC;QACV,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,OAAO,EAAE,CAAC,wBAAwB,CAAC;KACpC,CAAC;qCAK+B,eAAe,EAAgC,mBAAmB;GAJtF,QAAQ,CA2HpB;SA3HY,QAAQ","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {Injectable, InjectorService, ProviderScope, ProviderType, TokenProvider} from \"@tsed/di\";\nimport {concatPath, EndpointMetadata, getJsonEntityStore, getOperationsRoutes, JsonEntityStore} from \"@tsed/schema\";\nimport {buildRouter, createRouter, getRouter} from \"../builder/PlatformControllerBuilder\";\nimport {ControllerProvider} from \"../domain/ControllerProvider\";\nimport {PlatformRouteDetails} from \"../domain/PlatformRouteDetails\";\nimport {Route, RouteController} from \"../interfaces/Route\";\nimport {PlatformApplication} from \"./PlatformApplication\";\nimport {PlatformMiddlewaresChain} from \"./PlatformMiddlewaresChain\";\n\n/**\n * `Platform` is used to provide all routes collected by annotation `@Controller`.\n *\n * @platform\n */\n@Injectable({\n scope: ProviderScope.SINGLETON,\n imports: [PlatformMiddlewaresChain]\n})\nexport class Platform {\n private _routes: PlatformRouteDetails[] = [];\n private _controllers: RouteController[] = [];\n\n constructor(readonly injector: InjectorService, readonly platformApplication: PlatformApplication) {\n this.createRouters();\n }\n\n get app() {\n return this.platformApplication;\n }\n\n get routes(): PlatformRouteDetails[] {\n return this._routes;\n }\n\n public addRoutes(routes: Route[]) {\n routes.forEach((routeSettings) => {\n this.addRoute(routeSettings.route, routeSettings.token);\n });\n }\n\n public addRoute(basePath: string, token: TokenProvider) {\n const {injector} = this;\n const provider = injector.getProvider(token) as ControllerProvider;\n\n if (!provider || provider.hasParent()) {\n return;\n }\n\n this._controllers.push(...this.getAllControllers(basePath, token));\n\n const ctrlPath = concatPath(basePath, JsonEntityStore.from(provider.token).path);\n\n this.app.use(ctrlPath, ...[].concat(getRouter(injector, provider).callback()));\n\n this._routes = getOperationsRoutes<EndpointMetadata>(provider.token, {\n withChildren: true,\n basePath\n }).reduce((routes, operationRoute) => {\n if (injector.hasProvider(token)) {\n const provider = injector.getProvider(operationRoute.token) as ControllerProvider;\n const route = new PlatformRouteDetails({\n ...operationRoute,\n provider\n });\n\n routes = routes.concat(route);\n }\n\n return routes;\n }, this._routes);\n\n return this;\n }\n\n /**\n * Get all routes built by TsExpressDecorators and mounted on Express application.\n * @returns {PlatformRouteDetails[]}\n */\n public getRoutes(): PlatformRouteDetails[] {\n return this._routes;\n }\n\n /**\n * Get all controllers mounted on the application.\n * @returns {RouteController[]}\n */\n public getMountedControllers(): RouteController[] {\n return this._controllers;\n }\n\n protected $onInit() {\n this.buildControllers();\n }\n\n /**\n * Create routers from the collected controllers.\n * @private\n */\n private createRouters() {\n const {injector} = this;\n\n injector.getProviders(ProviderType.CONTROLLER).map((provider: ControllerProvider) => {\n createRouter(injector, provider);\n });\n }\n\n /**\n * Get all router controllers from the controller token.\n * @private\n */\n private getAllControllers(basePath: string, token: Type<any> | any): RouteController[] {\n const store: JsonEntityStore = token.isStore ? token : getJsonEntityStore(token);\n const ctrlPath = concatPath(basePath, JsonEntityStore.from(token).path);\n const children = store.get<Type[]>(\"childrenControllers\", []);\n\n return children\n .reduce<RouteController[]>((controllers, token) => {\n const childBasePath = concatPath(basePath, store.path);\n return controllers.concat(this.getAllControllers(childBasePath, token));\n }, [])\n .concat([\n {\n route: ctrlPath,\n provider: this.injector.getProvider(token) as ControllerProvider\n }\n ]);\n }\n\n /**\n * Create controllers from DI\n * @private\n */\n private buildControllers() {\n const {injector} = this;\n\n injector.getProviders(ProviderType.CONTROLLER).map((provider: ControllerProvider) => {\n if (!provider.hasParent()) {\n return buildRouter(injector, provider);\n }\n });\n }\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { InjectorService, registerProvider } from "@tsed/di";
2
+ import { FakeAdapter } from "./FakeAdapter.js";
3
+ export class PlatformAdapter {
4
+ }
5
+ registerProvider({
6
+ provide: PlatformAdapter,
7
+ deps: [InjectorService],
8
+ useClass: FakeAdapter
9
+ });
10
+ //# sourceMappingURL=PlatformAdapter.js.map