@tsed/common 7.0.0-beta.2 → 7.0.0-beta.20

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 (305) hide show
  1. package/coverage.json +6 -0
  2. package/jest.config.js +9 -0
  3. package/lib/cjs/builder/PlatformBuilder.js +94 -65
  4. package/lib/cjs/builder/PlatformBuilder.js.map +1 -1
  5. package/lib/cjs/config/interfaces/PlatformLoggerSettings.js.map +1 -1
  6. package/lib/cjs/config/interfaces/PlatformMulterSettings.js.map +1 -1
  7. package/lib/cjs/config/services/PlatformConfiguration.js +2 -66
  8. package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -1
  9. package/lib/cjs/decorators/multer/multipartFile.js.map +1 -1
  10. package/lib/cjs/decorators/params/error.js +1 -1
  11. package/lib/cjs/decorators/params/error.js.map +1 -1
  12. package/lib/cjs/domain/AnyToPromiseWithCtx.js +4 -5
  13. package/lib/cjs/domain/AnyToPromiseWithCtx.js.map +1 -1
  14. package/lib/cjs/domain/EndpointMetadata.js +2 -66
  15. package/lib/cjs/domain/EndpointMetadata.js.map +1 -1
  16. package/lib/cjs/domain/PlatformContext.js +46 -38
  17. package/lib/cjs/domain/PlatformContext.js.map +1 -1
  18. package/lib/cjs/domain/PlatformRouteDetails.js +0 -21
  19. package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -1
  20. package/lib/cjs/exports.js +32 -0
  21. package/lib/cjs/exports.js.map +1 -0
  22. package/lib/cjs/index.js +58 -30
  23. package/lib/cjs/index.js.map +1 -1
  24. package/lib/cjs/interfaces/PlatformRouteOptions.js.map +1 -1
  25. package/lib/cjs/interfaces/Route.js.map +1 -1
  26. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js +10 -9
  27. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
  28. package/lib/cjs/middlewares/PlatformMulterMiddleware.js +27 -13
  29. package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -1
  30. package/lib/cjs/package.json +3 -0
  31. package/lib/cjs/services/FakeAdapter.js +49 -0
  32. package/lib/cjs/services/FakeAdapter.js.map +1 -0
  33. package/lib/cjs/services/Platform.js +33 -68
  34. package/lib/cjs/services/Platform.js.map +1 -1
  35. package/lib/cjs/services/PlatformAdapter.js +24 -0
  36. package/lib/cjs/services/PlatformAdapter.js.map +1 -0
  37. package/lib/cjs/services/PlatformApplication.js +26 -14
  38. package/lib/cjs/services/PlatformApplication.js.map +1 -1
  39. package/lib/cjs/services/PlatformHandler.js +115 -172
  40. package/lib/cjs/services/PlatformHandler.js.map +1 -1
  41. package/lib/cjs/services/PlatformMiddlewaresChain.js +46 -19
  42. package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -1
  43. package/lib/cjs/services/PlatformRequest.js +17 -13
  44. package/lib/cjs/services/PlatformRequest.js.map +1 -1
  45. package/lib/cjs/services/PlatformResponse.js +20 -23
  46. package/lib/cjs/services/PlatformResponse.js.map +1 -1
  47. package/lib/cjs/services/PlatformTest.js +31 -10
  48. package/lib/cjs/services/PlatformTest.js.map +1 -1
  49. package/lib/cjs/utils/createContext.js +32 -21
  50. package/lib/cjs/utils/createContext.js.map +1 -1
  51. package/lib/cjs/utils/createHttpServer.js +6 -11
  52. package/lib/cjs/utils/createHttpServer.js.map +1 -1
  53. package/lib/cjs/utils/createHttpsServer.js +6 -11
  54. package/lib/cjs/utils/createHttpsServer.js.map +1 -1
  55. package/lib/cjs/utils/createInjector.js +16 -10
  56. package/lib/cjs/utils/createInjector.js.map +1 -1
  57. package/lib/cjs/utils/ensureContext.js +16 -0
  58. package/lib/cjs/utils/ensureContext.js.map +1 -0
  59. package/lib/cjs/utils/getConfiguration.js +6 -12
  60. package/lib/cjs/utils/getConfiguration.js.map +1 -1
  61. package/lib/cjs/utils/printRoutes.js +10 -8
  62. package/lib/cjs/utils/printRoutes.js.map +1 -1
  63. package/lib/cjs/utils/setResponseHeaders.js +8 -14
  64. package/lib/cjs/utils/setResponseHeaders.js.map +1 -1
  65. package/lib/esm/builder/PlatformBuilder.js +74 -68
  66. package/lib/esm/builder/PlatformBuilder.js.map +1 -1
  67. package/lib/esm/config/interfaces/PlatformLoggerSettings.js.map +1 -1
  68. package/lib/esm/config/interfaces/PlatformMulterSettings.js.map +1 -1
  69. package/lib/esm/config/services/PlatformConfiguration.js +0 -64
  70. package/lib/esm/config/services/PlatformConfiguration.js.map +1 -1
  71. package/lib/esm/decorators/multer/multerFileSize.js +1 -1
  72. package/lib/esm/decorators/multer/multerOptions.js +1 -1
  73. package/lib/esm/decorators/multer/multipartFile.js +1 -1
  74. package/lib/esm/decorators/multer/multipartFile.js.map +1 -1
  75. package/lib/esm/decorators/params/error.js +1 -1
  76. package/lib/esm/decorators/params/error.js.map +1 -1
  77. package/lib/esm/domain/AnyToPromiseWithCtx.js +4 -5
  78. package/lib/esm/domain/AnyToPromiseWithCtx.js.map +1 -1
  79. package/lib/esm/domain/EndpointMetadata.js +1 -66
  80. package/lib/esm/domain/EndpointMetadata.js.map +1 -1
  81. package/lib/esm/domain/PlatformContext.js +49 -41
  82. package/lib/esm/domain/PlatformContext.js.map +1 -1
  83. package/lib/esm/domain/PlatformRouteDetails.js +1 -19
  84. package/lib/esm/domain/PlatformRouteDetails.js.map +1 -1
  85. package/lib/esm/exports.js +14 -0
  86. package/lib/esm/exports.js.map +1 -0
  87. package/lib/esm/index.js +58 -27
  88. package/lib/esm/index.js.map +1 -1
  89. package/lib/esm/interfaces/PlatformRouteOptions.js.map +1 -1
  90. package/lib/esm/interfaces/Route.js.map +1 -1
  91. package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js +2 -1
  92. package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
  93. package/lib/esm/middlewares/PlatformMulterMiddleware.js +18 -5
  94. package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +1 -1
  95. package/lib/esm/package.json +3 -0
  96. package/lib/esm/services/FakeAdapter.js +45 -0
  97. package/lib/esm/services/FakeAdapter.js.map +1 -0
  98. package/lib/esm/services/Platform.js +34 -69
  99. package/lib/esm/services/Platform.js.map +1 -1
  100. package/lib/esm/services/PlatformAdapter.js +20 -0
  101. package/lib/esm/services/PlatformAdapter.js.map +1 -0
  102. package/lib/esm/services/PlatformApplication.js +27 -15
  103. package/lib/esm/services/PlatformApplication.js.map +1 -1
  104. package/lib/esm/services/PlatformHandler.js +116 -173
  105. package/lib/esm/services/PlatformHandler.js.map +1 -1
  106. package/lib/esm/services/PlatformMiddlewaresChain.js +49 -22
  107. package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -1
  108. package/lib/esm/services/PlatformRequest.js +16 -12
  109. package/lib/esm/services/PlatformRequest.js.map +1 -1
  110. package/lib/esm/services/PlatformResponse.js +19 -22
  111. package/lib/esm/services/PlatformResponse.js.map +1 -1
  112. package/lib/esm/services/PlatformTest.js +34 -14
  113. package/lib/esm/services/PlatformTest.js.map +1 -1
  114. package/lib/esm/utils/createContext.js +33 -23
  115. package/lib/esm/utils/createContext.js.map +1 -1
  116. package/lib/esm/utils/createHttpServer.js +6 -11
  117. package/lib/esm/utils/createHttpServer.js.map +1 -1
  118. package/lib/esm/utils/createHttpsServer.js +6 -11
  119. package/lib/esm/utils/createHttpsServer.js.map +1 -1
  120. package/lib/esm/utils/createInjector.js +20 -14
  121. package/lib/esm/utils/createInjector.js.map +1 -1
  122. package/lib/esm/utils/ensureContext.js +12 -0
  123. package/lib/esm/utils/ensureContext.js.map +1 -0
  124. package/lib/esm/utils/getConfiguration.js +8 -14
  125. package/lib/esm/utils/getConfiguration.js.map +1 -1
  126. package/lib/esm/utils/printRoutes.js +10 -8
  127. package/lib/esm/utils/printRoutes.js.map +1 -1
  128. package/lib/esm/utils/setResponseHeaders.js +8 -14
  129. package/lib/esm/utils/setResponseHeaders.js.map +1 -1
  130. package/lib/types/builder/PlatformBuilder.d.ts +19 -17
  131. package/lib/types/config/interfaces/PlatformLoggerSettings.d.ts +2 -43
  132. package/lib/types/config/interfaces/PlatformMulterSettings.d.ts +6 -130
  133. package/lib/types/config/services/PlatformConfiguration.d.ts +6 -21
  134. package/lib/types/domain/AnyToPromiseWithCtx.d.ts +1 -9
  135. package/lib/types/domain/EndpointMetadata.d.ts +1 -50
  136. package/lib/types/domain/PlatformContext.d.ts +32 -18
  137. package/lib/types/domain/PlatformRouteDetails.d.ts +4 -20
  138. package/lib/types/exports.d.ts +13 -0
  139. package/lib/types/index.d.ts +56 -18
  140. package/lib/types/interfaces/PlatformRouteOptions.d.ts +1 -2
  141. package/lib/types/interfaces/Route.d.ts +2 -3
  142. package/lib/types/middlewares/PlatformMulterMiddleware.d.ts +8 -3
  143. package/lib/types/services/FakeAdapter.d.ts +31 -0
  144. package/lib/types/services/Platform.d.ts +9 -21
  145. package/lib/types/services/PlatformAdapter.d.ts +58 -0
  146. package/lib/types/services/PlatformApplication.d.ts +15 -7
  147. package/lib/types/services/PlatformHandler.d.ts +21 -59
  148. package/lib/types/services/PlatformMiddlewaresChain.d.ts +6 -3
  149. package/lib/types/services/PlatformRequest.d.ts +8 -10
  150. package/lib/types/services/PlatformResponse.d.ts +15 -19
  151. package/lib/types/services/PlatformTest.d.ts +5 -4
  152. package/lib/types/utils/createContext.d.ts +4 -1
  153. package/lib/types/utils/createHttpServer.d.ts +1 -1
  154. package/lib/types/utils/createHttpsServer.d.ts +3 -1
  155. package/lib/types/utils/createInjector.d.ts +5 -3
  156. package/lib/types/utils/ensureContext.d.ts +2 -0
  157. package/lib/types/utils/listenServer.d.ts +2 -0
  158. package/package.json +43 -26
  159. package/readme.md +52 -58
  160. package/tsconfig.compile.esm.json +2 -12
  161. package/lib/cjs/builder/PlatformControllerBuilder.js +0 -85
  162. package/lib/cjs/builder/PlatformControllerBuilder.js.map +0 -1
  163. package/lib/cjs/config/index.js +0 -7
  164. package/lib/cjs/config/index.js.map +0 -1
  165. package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.js +0 -3
  166. package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.js.map +0 -1
  167. package/lib/cjs/config/interfaces/index.js +0 -8
  168. package/lib/cjs/config/interfaces/index.js.map +0 -1
  169. package/lib/cjs/decorators/httpServer.js +0 -32
  170. package/lib/cjs/decorators/httpServer.js.map +0 -1
  171. package/lib/cjs/decorators/httpsServer.js +0 -32
  172. package/lib/cjs/decorators/httpsServer.js.map +0 -1
  173. package/lib/cjs/decorators/index.js +0 -21
  174. package/lib/cjs/decorators/index.js.map +0 -1
  175. package/lib/cjs/decorators/method/acceptMime.js +0 -28
  176. package/lib/cjs/decorators/method/acceptMime.js.map +0 -1
  177. package/lib/cjs/decorators/method/endpointFn.js +0 -15
  178. package/lib/cjs/decorators/method/endpointFn.js.map +0 -1
  179. package/lib/cjs/decorators/method/location.js +0 -6
  180. package/lib/cjs/decorators/method/location.js.map +0 -1
  181. package/lib/cjs/decorators/method/redirect.js +0 -6
  182. package/lib/cjs/decorators/method/redirect.js.map +0 -1
  183. package/lib/cjs/decorators/method/route.js +0 -13
  184. package/lib/cjs/decorators/method/route.js.map +0 -1
  185. package/lib/cjs/decorators/method/view.js +0 -34
  186. package/lib/cjs/decorators/method/view.js.map +0 -1
  187. package/lib/cjs/decorators/multer/index.js +0 -7
  188. package/lib/cjs/decorators/multer/index.js.map +0 -1
  189. package/lib/cjs/domain/ControllerProvider.js +0 -51
  190. package/lib/cjs/domain/ControllerProvider.js.map +0 -1
  191. package/lib/cjs/domain/HandlerMetadata.js +0 -57
  192. package/lib/cjs/domain/HandlerMetadata.js.map +0 -1
  193. package/lib/cjs/domain/index.js +0 -10
  194. package/lib/cjs/domain/index.js.map +0 -1
  195. package/lib/cjs/interfaces/PathType.js +0 -3
  196. package/lib/cjs/interfaces/PathType.js.map +0 -1
  197. package/lib/cjs/interfaces/PlatformAdapter.js +0 -3
  198. package/lib/cjs/interfaces/PlatformAdapter.js.map +0 -1
  199. package/lib/cjs/interfaces/index.js +0 -21
  200. package/lib/cjs/interfaces/index.js.map +0 -1
  201. package/lib/cjs/middlewares/__mock__/FakeCtrl.js +0 -12
  202. package/lib/cjs/middlewares/__mock__/FakeCtrl.js.map +0 -1
  203. package/lib/cjs/middlewares/bindEndpointMiddleware.js +0 -13
  204. package/lib/cjs/middlewares/bindEndpointMiddleware.js.map +0 -1
  205. package/lib/cjs/middlewares/index.js +0 -7
  206. package/lib/cjs/middlewares/index.js.map +0 -1
  207. package/lib/cjs/services/FakeRawDriver.js +0 -26
  208. package/lib/cjs/services/FakeRawDriver.js.map +0 -1
  209. package/lib/cjs/services/PlatformRouter.js +0 -126
  210. package/lib/cjs/services/PlatformRouter.js.map +0 -1
  211. package/lib/cjs/services/index.js +0 -12
  212. package/lib/cjs/services/index.js.map +0 -1
  213. package/lib/cjs/utils/createHandlerMetadata.js +0 -49
  214. package/lib/cjs/utils/createHandlerMetadata.js.map +0 -1
  215. package/lib/cjs/utils/index.js +0 -11
  216. package/lib/cjs/utils/index.js.map +0 -1
  217. package/lib/cjs/utils/useCtxHandler.js +0 -15
  218. package/lib/cjs/utils/useCtxHandler.js.map +0 -1
  219. package/lib/esm/builder/PlatformControllerBuilder.js +0 -79
  220. package/lib/esm/builder/PlatformControllerBuilder.js.map +0 -1
  221. package/lib/esm/config/index.js +0 -4
  222. package/lib/esm/config/index.js.map +0 -1
  223. package/lib/esm/config/interfaces/EndpointDirectoriesSettings.js +0 -2
  224. package/lib/esm/config/interfaces/EndpointDirectoriesSettings.js.map +0 -1
  225. package/lib/esm/config/interfaces/index.js +0 -5
  226. package/lib/esm/config/interfaces/index.js.map +0 -1
  227. package/lib/esm/decorators/httpServer.js +0 -28
  228. package/lib/esm/decorators/httpServer.js.map +0 -1
  229. package/lib/esm/decorators/httpsServer.js +0 -28
  230. package/lib/esm/decorators/httpsServer.js.map +0 -1
  231. package/lib/esm/decorators/index.js +0 -18
  232. package/lib/esm/decorators/index.js.map +0 -1
  233. package/lib/esm/decorators/method/acceptMime.js +0 -24
  234. package/lib/esm/decorators/method/acceptMime.js.map +0 -1
  235. package/lib/esm/decorators/method/endpointFn.js +0 -11
  236. package/lib/esm/decorators/method/endpointFn.js.map +0 -1
  237. package/lib/esm/decorators/method/location.js +0 -2
  238. package/lib/esm/decorators/method/location.js.map +0 -1
  239. package/lib/esm/decorators/method/redirect.js +0 -2
  240. package/lib/esm/decorators/method/redirect.js.map +0 -1
  241. package/lib/esm/decorators/method/route.js +0 -2
  242. package/lib/esm/decorators/method/route.js.map +0 -1
  243. package/lib/esm/decorators/method/view.js +0 -30
  244. package/lib/esm/decorators/method/view.js.map +0 -1
  245. package/lib/esm/decorators/multer/index.js +0 -4
  246. package/lib/esm/decorators/multer/index.js.map +0 -1
  247. package/lib/esm/domain/ControllerProvider.js +0 -47
  248. package/lib/esm/domain/ControllerProvider.js.map +0 -1
  249. package/lib/esm/domain/HandlerMetadata.js +0 -53
  250. package/lib/esm/domain/HandlerMetadata.js.map +0 -1
  251. package/lib/esm/domain/index.js +0 -7
  252. package/lib/esm/domain/index.js.map +0 -1
  253. package/lib/esm/interfaces/PathType.js +0 -2
  254. package/lib/esm/interfaces/PathType.js.map +0 -1
  255. package/lib/esm/interfaces/PlatformAdapter.js +0 -2
  256. package/lib/esm/interfaces/PlatformAdapter.js.map +0 -1
  257. package/lib/esm/interfaces/index.js +0 -18
  258. package/lib/esm/interfaces/index.js.map +0 -1
  259. package/lib/esm/middlewares/__mock__/FakeCtrl.js +0 -9
  260. package/lib/esm/middlewares/__mock__/FakeCtrl.js.map +0 -1
  261. package/lib/esm/middlewares/bindEndpointMiddleware.js +0 -9
  262. package/lib/esm/middlewares/bindEndpointMiddleware.js.map +0 -1
  263. package/lib/esm/middlewares/index.js +0 -4
  264. package/lib/esm/middlewares/index.js.map +0 -1
  265. package/lib/esm/services/FakeRawDriver.js +0 -22
  266. package/lib/esm/services/FakeRawDriver.js.map +0 -1
  267. package/lib/esm/services/PlatformRouter.js +0 -123
  268. package/lib/esm/services/PlatformRouter.js.map +0 -1
  269. package/lib/esm/services/index.js +0 -9
  270. package/lib/esm/services/index.js.map +0 -1
  271. package/lib/esm/utils/createHandlerMetadata.js +0 -45
  272. package/lib/esm/utils/createHandlerMetadata.js.map +0 -1
  273. package/lib/esm/utils/index.js +0 -8
  274. package/lib/esm/utils/index.js.map +0 -1
  275. package/lib/esm/utils/useCtxHandler.js +0 -11
  276. package/lib/esm/utils/useCtxHandler.js.map +0 -1
  277. package/lib/types/builder/PlatformControllerBuilder.d.ts +0 -17
  278. package/lib/types/config/index.d.ts +0 -3
  279. package/lib/types/config/interfaces/EndpointDirectoriesSettings.d.ts +0 -3
  280. package/lib/types/config/interfaces/index.d.ts +0 -97
  281. package/lib/types/decorators/httpServer.d.ts +0 -28
  282. package/lib/types/decorators/httpsServer.d.ts +0 -28
  283. package/lib/types/decorators/index.d.ts +0 -14
  284. package/lib/types/decorators/method/acceptMime.d.ts +0 -19
  285. package/lib/types/decorators/method/endpointFn.d.ts +0 -9
  286. package/lib/types/decorators/method/location.d.ts +0 -1
  287. package/lib/types/decorators/method/redirect.d.ts +0 -1
  288. package/lib/types/decorators/method/route.d.ts +0 -1
  289. package/lib/types/decorators/method/view.d.ts +0 -25
  290. package/lib/types/decorators/multer/index.d.ts +0 -3
  291. package/lib/types/domain/ControllerProvider.d.ts +0 -24
  292. package/lib/types/domain/HandlerMetadata.d.ts +0 -32
  293. package/lib/types/domain/index.d.ts +0 -6
  294. package/lib/types/interfaces/PathType.d.ts +0 -1
  295. package/lib/types/interfaces/PlatformAdapter.d.ts +0 -19
  296. package/lib/types/interfaces/index.d.ts +0 -17
  297. package/lib/types/middlewares/__mock__/FakeCtrl.d.ts +0 -2
  298. package/lib/types/middlewares/bindEndpointMiddleware.d.ts +0 -5
  299. package/lib/types/middlewares/index.d.ts +0 -3
  300. package/lib/types/services/FakeRawDriver.d.ts +0 -15
  301. package/lib/types/services/PlatformRouter.d.ts +0 -48
  302. package/lib/types/services/index.d.ts +0 -8
  303. package/lib/types/utils/createHandlerMetadata.d.ts +0 -8
  304. package/lib/types/utils/index.d.ts +0 -7
  305. package/lib/types/utils/useCtxHandler.d.ts +0 -13
@@ -1,9 +1,12 @@
1
1
  import { InjectorService } from "@tsed/di";
2
2
  import { PlatformContext } from "../domain/PlatformContext";
3
3
  import { IncomingEvent } from "../interfaces/IncomingEvent";
4
+ import { PlatformRequest } from "../services/PlatformRequest";
5
+ import { PlatformResponse } from "../services/PlatformResponse";
6
+ export declare function buildIgnoreLog(ignoreUrlPatterns: any[] | undefined): ((ignore: boolean, data: any, url: string) => any) | undefined;
4
7
  /**
5
8
  * Create the TsED context to wrap request, response, injector, etc...
6
9
  * @param injector
7
10
  * @ignore
8
11
  */
9
- export declare function createContext(injector: InjectorService): (event: IncomingEvent) => Promise<PlatformContext>;
12
+ export declare function createContext(injector: InjectorService): (event: IncomingEvent) => Promise<PlatformContext<PlatformRequest<any>, PlatformResponse<any>>>;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="node" />
2
2
  import { InjectorService } from "@tsed/di";
3
3
  import Http from "http";
4
- export declare function createHttpServer(injector: InjectorService, requestListener: Http.RequestListener): (() => Promise<void>) | undefined;
4
+ export declare function createHttpServer(injector: InjectorService, requestListener: Http.RequestListener): (() => Promise<Http.Server>) | undefined;
@@ -1,4 +1,6 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { InjectorService } from "@tsed/di";
4
+ import Https from "https";
3
5
  import Http from "http";
4
- export declare function createHttpsServer(injector: InjectorService, requestListener?: Http.RequestListener): (() => Promise<void>) | undefined;
6
+ export declare function createHttpsServer(injector: InjectorService, requestListener?: Http.RequestListener): (() => Promise<Https.Server>) | undefined;
@@ -1,7 +1,9 @@
1
- import { InjectorService, IProvider } from "@tsed/di";
1
+ import { Type } from "@tsed/core";
2
+ import { InjectorService } from "@tsed/di";
3
+ import { PlatformAdapter } from "../services/PlatformAdapter";
2
4
  interface CreateInjectorOptions {
3
- providers?: IProvider[];
5
+ adapter?: Type<PlatformAdapter<any>>;
4
6
  settings?: Partial<TsED.Configuration>;
5
7
  }
6
- export declare function createInjector({ providers, settings }: CreateInjectorOptions): InjectorService;
8
+ export declare function createInjector({ adapter, settings }: CreateInjectorOptions): InjectorService;
7
9
  export {};
@@ -0,0 +1,2 @@
1
+ import { PlatformContext } from "../domain/PlatformContext";
2
+ export declare function ensureContext(request: any, cb: ($ctx: PlatformContext) => any, fallback?: () => void): any;
@@ -1,4 +1,6 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
2
4
  import type Http from "http";
3
5
  import type Https from "https";
4
6
  import type Http2 from "http2";
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@tsed/common",
3
- "version": "7.0.0-beta.2",
3
+ "version": "7.0.0-beta.20",
4
4
  "description": "A TypeScript Framework on top of Express",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
7
7
  "main": "./lib/cjs/index.js",
8
+ "module": "./lib/esm/index.js",
8
9
  "typings": "./lib/types/index.d.ts",
9
10
  "exports": {
10
11
  "types": "./lib/types/index.d.ts",
@@ -13,9 +14,11 @@
13
14
  "default": "./lib/esm/index.js"
14
15
  },
15
16
  "scripts": {
16
- "build": "yarn run build:esm && yarn run build:cjs",
17
+ "build": "yarn barrels && yarn run build:esm && yarn run build:cjs",
17
18
  "build:cjs": "tsc --build tsconfig.compile.json",
18
- "build:esm": "tsc --build tsconfig.compile.esm.json"
19
+ "build:esm": "tsc --build tsconfig.compile.esm.json",
20
+ "barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\" -e \"getConfiguration\"",
21
+ "test": "cross-env NODE_ENV=test yarn jest --max-workers=2"
19
22
  },
20
23
  "keywords": [
21
24
  "Express",
@@ -46,7 +49,7 @@
46
49
  "bugs": {
47
50
  "url": "https://github.com/tsedio/tsed/issues"
48
51
  },
49
- "homepage": "https://github.com/tsedio/tsed/tree/alpha/packages/platform/common",
52
+ "homepage": "https://github.com/tsedio/tsed/tree/beta/packages/platform/common",
50
53
  "repository": "https://github.com/tsedio/tsed",
51
54
  "funding": [
52
55
  {
@@ -59,29 +62,43 @@
59
62
  }
60
63
  ],
61
64
  "dependencies": {
62
- "@tsed/components-scan": "7.0.0-beta.2",
63
- "@tsed/core": "7.0.0-beta.2",
64
- "@tsed/di": "7.0.0-beta.2",
65
- "@tsed/exceptions": "7.0.0-beta.2",
66
- "@tsed/json-mapper": "7.0.0-beta.2",
67
- "@tsed/logger": "^6.0.0",
68
- "@tsed/logger-file": "^6.0.0",
69
- "@tsed/perf": "7.0.0-beta.2",
70
- "@tsed/platform-cache": "7.0.0-beta.2",
71
- "@tsed/platform-exceptions": "7.0.0-beta.2",
72
- "@tsed/platform-log-middleware": "7.0.0-beta.2",
73
- "@tsed/platform-middlewares": "7.0.0-beta.2",
74
- "@tsed/platform-params": "7.0.0-beta.2",
75
- "@tsed/platform-response-filter": "7.0.0-beta.2",
76
- "@tsed/platform-views": "7.0.0-beta.2",
77
- "@tsed/schema": "7.0.0-beta.2",
78
- "@types/json-schema": "7.0.7",
79
- "on-finished": "2.3.0",
80
- "tslib": "2.2.0",
65
+ "@tsed/components-scan": "7.0.0-beta.20",
66
+ "@tsed/core": "7.0.0-beta.20",
67
+ "@tsed/di": "7.0.0-beta.20",
68
+ "@tsed/exceptions": "7.0.0-beta.20",
69
+ "@tsed/json-mapper": "7.0.0-beta.20",
70
+ "@tsed/logger": ">=6.2.0",
71
+ "@tsed/logger-file": ">=6.2.0",
72
+ "@tsed/perf": "7.0.0-beta.20",
73
+ "@tsed/platform-cache": "7.0.0-beta.20",
74
+ "@tsed/platform-exceptions": "7.0.0-beta.20",
75
+ "@tsed/platform-log-middleware": "7.0.0-beta.20",
76
+ "@tsed/platform-middlewares": "7.0.0-beta.20",
77
+ "@tsed/platform-params": "7.0.0-beta.20",
78
+ "@tsed/platform-response-filter": "7.0.0-beta.20",
79
+ "@tsed/platform-router": "7.0.0-beta.20",
80
+ "@tsed/platform-views": "7.0.0-beta.20",
81
+ "@tsed/schema": "7.0.0-beta.20",
82
+ "@types/json-schema": "7.0.11",
83
+ "@types/on-finished": "2.3.1",
84
+ "on-finished": "2.4.1",
85
+ "tslib": "2.4.0",
81
86
  "uuid": "8.3.2"
82
87
  },
83
- "devDependencies": {
84
- "rxjs": "^6.5.2"
88
+ "peerDependencies": {
89
+ "@tsed/logger": ">=6.2.0",
90
+ "@tsed/logger-file": ">=6.2.0"
85
91
  },
86
- "peerDependencies": {}
92
+ "peerDependenciesMeta": {
93
+ "@tsed/logger": {
94
+ "optional": false
95
+ },
96
+ "@tsed/logger-file": {
97
+ "optional": false
98
+ }
99
+ },
100
+ "devDependencies": {},
101
+ "publishConfig": {
102
+ "tag": "beta"
103
+ }
87
104
  }
package/readme.md CHANGED
@@ -11,7 +11,8 @@
11
11
  [![npm version](https://badge.fury.io/js/%40tsed%2Fcommon.svg)](https://badge.fury.io/js/%40tsed%2Fcommon)
12
12
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
13
13
  [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
14
- [![backers](https://opencollective.com/tsed/tiers/badge.svg)](https://opencollective.com/tsed)
14
+ [![github](https://img.shields.io/static/v1?label=Github%20sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86)](https://github.com/sponsors/romakita)
15
+ [![opencollective](https://img.shields.io/static/v1?label=OpenCollective%20sponsor&message=%E2%9D%A4&logo=OpenCollective&color=%23fe8e86)](https://opencollective.com/tsed)
15
16
 
16
17
  </div>
17
18
 
@@ -31,32 +32,32 @@
31
32
 
32
33
  ## What it is
33
34
 
34
- Ts.ED is a framework on top of Express that helps you to write your application in TypeScript (or in ES6). It provides a lot of decorators
35
+ Ts.ED is a framework on top of Express that helps you to write your application in TypeScript (or in ES6). It provides a lot of decorators
35
36
  to make your code more readable and less error-prone.
36
37
 
37
38
  ## Features
38
39
 
39
- * Use our CLI to create a new project https://cli.tsed.io
40
- * Support TypeORM, Mongoose, GraphQL, Socket.io, Swagger-ui, Passport.js, etc...
41
- * Define class as Controller,
42
- * Define class as Service (IoC),
43
- * Define class as Middleware and MiddlewareError,
44
- * Define class as Converter (POJ to Model and Model to POJ),
45
- * Define root path for an entire controller and versioning your Rest API,
46
- * Define as sub-route path for a method,
47
- * Define routes on GET, POST, PUT, DELETE and HEAD verbs,
48
- * Define middlewares on routes,
49
- * Define required parameters,
50
- * Inject data from query string, path parameters, entire body, cookies, session or header,
51
- * Inject Request, Response, Next object from Express request,
52
- * Template (View),
53
- * Testing.
40
+ - Use our CLI to create a new project https://cli.tsed.io
41
+ - Support TypeORM, Mongoose, GraphQL, Socket.io, Swagger-ui, Passport.js, etc...
42
+ - Define class as Controller,
43
+ - Define class as Service (IoC),
44
+ - Define class as Middleware and MiddlewareError,
45
+ - Define class as Converter (POJ to Model and Model to POJ),
46
+ - Define root path for an entire controller and versioning your Rest API,
47
+ - Define as sub-route path for a method,
48
+ - Define routes on GET, POST, PUT, DELETE and HEAD verbs,
49
+ - Define middlewares on routes,
50
+ - Define required parameters,
51
+ - Inject data from query string, path parameters, entire body, cookies, session or header,
52
+ - Inject Request, Response, Next object from Express request,
53
+ - Template (View),
54
+ - Testing.
54
55
 
55
56
  ## Documentation
56
57
 
57
58
  Documentation is available on [https://tsed.io](https://tsed.io)
58
59
 
59
- ## Getting started
60
+ ## Getting started
60
61
 
61
62
  See our [getting started here](https://tsed.io/getting-started/) to create new Ts.ED project or use
62
63
  our [CLI](https://cli.tsed.io)
@@ -65,8 +66,8 @@ our [CLI](https://cli.tsed.io)
65
66
 
66
67
  Examples are available on [https://tsed.io/tutorials/](https://tsed.io/tutorials/)
67
68
 
68
-
69
69
  ## Overview
70
+
70
71
  ### Server example
71
72
 
72
73
  Here an example to create a Server with Ts.ED:
@@ -75,37 +76,19 @@ Here an example to create a Server with Ts.ED:
75
76
  import {Configuration, Inject} from "@tsed/di";
76
77
  import {PlatformApplication} from "@tsed/common";
77
78
  import "@tsed/platform-express";
78
- import * as Path from "path";
79
-
80
- export const rootDir = Path.resolve(__dirname);
79
+ import Path from "path";
80
+ import cookieParser from "cookie-parser";
81
+ import compress from "compression";
82
+ import methodOverride from "method-override";
81
83
 
82
84
  @Configuration({
83
- rootDir,
84
- port: 3000
85
+ port: 3000,
86
+ middlewares: [cookieParser(), compress({}), methodOverride()]
85
87
  })
86
- export class Server {
87
- @Inject()
88
- app: PlatformApplication;
89
-
90
- public $beforeRoutesInit() {
91
- const cookieParser = require('cookie-parser'),
92
- bodyParser = require('body-parser'),
93
- compress = require('compression'),
94
- methodOverride = require('method-override');
95
-
96
- this.app
97
- .use(cookieParser())
98
- .use(compress({}))
99
- .use(methodOverride())
100
- .use(bodyParser.json())
101
- .use(bodyParser.urlencoded({
102
- extended: true
103
- }));
104
- }
105
- }
88
+ export class Server {}
106
89
  ```
107
90
 
108
- To run your server, you have to use Platform API to bootstrap your application with the expected
91
+ To run your server, you have to use Platform API to bootstrap your application with the expected
109
92
  platform like Express.
110
93
 
111
94
  ```typescript
@@ -137,21 +120,34 @@ This is a simple controller to expose user resource. It use decorators to build
137
120
  ```typescript
138
121
  import {Inject} from "@tsed/di";
139
122
  import {Summary} from "@tsed/swagger";
140
- import {Returns, ReturnsArray, Controller, Get, QueryParams, PathParams, Delete, Post, Required, BodyParams, Status, Put} from "@tsed/common";
123
+ import {
124
+ Returns,
125
+ ReturnsArray,
126
+ Controller,
127
+ Get,
128
+ QueryParams,
129
+ PathParams,
130
+ Delete,
131
+ Post,
132
+ Required,
133
+ BodyParams,
134
+ Status,
135
+ Put
136
+ } from "@tsed/common";
141
137
  import {BadRequest} from "@tsed/exceptions";
142
138
  import {UsersService} from "../services/UsersService";
143
- import {User} from "../models/User";
139
+ import {User} from "../models/User";
144
140
 
145
141
  @Controller("/users")
146
142
  export class UsersCtrl {
147
143
  @Inject()
148
- usersService: UsersService;
144
+ protected usersService: UsersService;
149
145
 
150
146
  @Get("/:id")
151
147
  @Summary("Get a user from his Id")
152
148
  @Returns(User)
153
149
  async getUser(@PathParams("id") id: string): Promise<User> {
154
- return this.usersService.findById(id);
150
+ return this.usersService.findById(id);
155
151
  }
156
152
 
157
153
  @Post("/")
@@ -168,41 +164,40 @@ export class UsersCtrl {
168
164
  @Returns(User)
169
165
  async putUser(@PathParams("id") id: string, @Required() @BodyParams() user: User): Promise<User> {
170
166
  if (user.id !== id) {
171
- throw new BadRequest("ID mismatch with the given payload")
167
+ throw new BadRequest("ID mismatch with the given payload");
172
168
  }
173
169
 
174
170
  return this.usersService.save(user);
175
171
  }
176
-
172
+
177
173
  @Delete("/:id")
178
174
  @Summary("Remove a user")
179
175
  @Status(204)
180
- async deleteUser(@PathParams("id") @Required() id: string ): Promise<User> {
181
- await this.usersService.delete(user);
176
+ async deleteUser(@PathParams("id") @Required() id: string): Promise<User> {
177
+ await this.usersService.delete(user);
182
178
  }
183
-
179
+
184
180
  @Get("/")
185
181
  @Summary("Get all users")
186
182
  @ReturnsArray(User)
187
- async findUser(@QueryParams("name") name: string){
183
+ async findUser(@QueryParams("name") name: string) {
188
184
  return this.usersService.find({name});
189
185
  }
190
186
  }
191
187
  ```
192
188
 
193
189
  ## Contributors
190
+
194
191
  Please read [contributing guidelines here](./CONTRIBUTING.md).
195
192
 
196
193
  <a href="https://github.com/tsedio/tsed/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>
197
194
 
198
-
199
195
  ## Backers
200
196
 
201
197
  Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]
202
198
 
203
199
  <a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/tiers/backer.svg?width=890"></a>
204
200
 
205
-
206
201
  ## Sponsors
207
202
 
208
203
  Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
@@ -220,4 +215,3 @@ The above copyright notice and this permission notice shall be included in all c
220
215
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
221
216
 
222
217
  [travis]: https://travis-ci.org/
223
-
@@ -8,16 +8,6 @@
8
8
  "declaration": true,
9
9
  "declarationDir": "./lib/types"
10
10
  },
11
- "exclude": [
12
- "node_modules",
13
- "test",
14
- "lib",
15
- "benchmark",
16
- "coverage",
17
- "spec",
18
- "**/*.benchmark.ts",
19
- "**/*.spec.ts",
20
- "keys",
21
- "jest.config.js"
22
- ]
11
+ "include": ["src"],
12
+ "exclude": ["node_modules", "test", "lib", "benchmark", "coverage", "spec", "**/*.benchmark.ts", "**/*.spec.ts", "keys", "jest.config.js"]
23
13
  }
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildRouter = exports.createRouter = exports.getRouter = void 0;
4
- const di_1 = require("@tsed/di");
5
- const schema_1 = require("@tsed/schema");
6
- const ControllerProvider_1 = require("../domain/ControllerProvider");
7
- const PlatformRouter_1 = require("../services/PlatformRouter");
8
- const PlatformMiddlewaresChain_1 = require("../services/PlatformMiddlewaresChain");
9
- di_1.GlobalProviders.createRegistry(di_1.ProviderType.CONTROLLER, ControllerProvider_1.ControllerProvider, {
10
- onInvoke(provider, locals, { injector }) {
11
- const router = createRouter(injector, provider);
12
- locals.set(PlatformRouter_1.PlatformRouter, router);
13
- }
14
- });
15
- /**
16
- * @ignore
17
- */
18
- function formatMethod(method) {
19
- return (method === schema_1.OperationMethods.CUSTOM ? "use" : method || "use").toLowerCase();
20
- }
21
- /**
22
- * @ignore
23
- */
24
- function getRouter(injector, provider) {
25
- return injector.get(provider.tokenRouter);
26
- }
27
- exports.getRouter = getRouter;
28
- /**
29
- * @ignore
30
- */
31
- function createRouter(injector, provider) {
32
- const token = provider.tokenRouter;
33
- if (injector.has(token)) {
34
- return getRouter(injector, provider);
35
- }
36
- const router = PlatformRouter_1.PlatformRouter.create(injector, provider.routerOptions);
37
- return injector
38
- .add(token, {
39
- useValue: router
40
- })
41
- .invoke(token);
42
- }
43
- exports.createRouter = createRouter;
44
- /**
45
- * @ignore
46
- * @param injector
47
- * @param provider
48
- */
49
- function buildRouter(injector, provider) {
50
- const { middlewares: { useBefore }, children } = provider;
51
- // Controller lifecycle
52
- const router = createRouter(injector, provider);
53
- if (!router.isBuilt) {
54
- router.isBuilt = true;
55
- const platformMiddlewaresChain = injector.get(PlatformMiddlewaresChain_1.PlatformMiddlewaresChain);
56
- useBefore // Controller before-middleware
57
- .filter((o) => typeof o === "function")
58
- .forEach((middleware) => {
59
- router.use(middleware);
60
- });
61
- // build all endpoints and his middlewares
62
- (0, schema_1.getOperationsRoutes)(provider.token).forEach((operationRoute) => {
63
- const handlers = platformMiddlewaresChain === null || platformMiddlewaresChain === void 0 ? void 0 : platformMiddlewaresChain.get(provider, operationRoute);
64
- router.addRoute({
65
- handlers,
66
- token: operationRoute.token,
67
- method: formatMethod(operationRoute.method),
68
- path: operationRoute.path,
69
- isFinal: operationRoute.isFinal
70
- });
71
- });
72
- // build children controllers
73
- children.forEach((child) => {
74
- const childProvider = injector.getProvider(child);
75
- /* istanbul ignore next */
76
- if (!childProvider) {
77
- throw new Error("Controller component not found in the ControllerRegistry");
78
- }
79
- router.use(childProvider.path, buildRouter(injector, childProvider));
80
- });
81
- }
82
- return router;
83
- }
84
- exports.buildRouter = buildRouter;
85
- //# sourceMappingURL=PlatformControllerBuilder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformControllerBuilder.js","sourceRoot":"","sources":["../../../src/builder/PlatformControllerBuilder.ts"],"names":[],"mappings":";;;AACA,iCAAwE;AACxE,yCAAmE;AACnE,qEAAgE;AAChE,+DAA0D;AAE1D,mFAA8E;AAE9E,oBAAe,CAAC,cAAc,CAAC,iBAAY,CAAC,UAAU,EAAE,uCAAkB,EAAE;IAC1E,QAAQ,CAAC,QAA4B,EAAE,MAAW,EAAE,EAAC,QAAQ,EAAC;QAC5D,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAChD,MAAM,CAAC,GAAG,CAAC,+BAAc,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC;CACF,CAAC,CAAC;AAEH;;GAEG;AACH,SAAS,YAAY,CAAC,MAA0B;IAC9C,OAAO,CAAC,MAAM,KAAK,yBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AACtF,CAAC;AAED;;GAEG;AACH,SAAgB,SAAS,CAAC,QAAyB,EAAE,QAA4B;IAC/E,OAAO,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAE,CAAC;AAC7C,CAAC;AAFD,8BAEC;AAED;;GAEG;AACH,SAAgB,YAAY,CAAC,QAAyB,EAAE,QAA4B;IAClF,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,CAAC;IAEnC,IAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QACvB,OAAO,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;KACtC;IAED,MAAM,MAAM,GAAG,+BAAc,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IAEvE,OAAO,QAAQ;SACZ,GAAG,CAAC,KAAK,EAAE;QACV,QAAQ,EAAE,MAAM;KACjB,CAAC;SACD,MAAM,CAAiB,KAAK,CAAC,CAAC;AACnC,CAAC;AAdD,oCAcC;AAED;;;;GAIG;AACH,SAAgB,WAAW,CAAC,QAAyB,EAAE,QAA4B;IACjF,MAAM,EACJ,WAAW,EAAE,EAAC,SAAS,EAAC,EACxB,QAAQ,EACT,GAAG,QAAQ,CAAC;IAEb,uBAAuB;IACvB,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAEhD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;QACnB,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;QAEtB,MAAM,wBAAwB,GAAG,QAAQ,CAAC,GAAG,CAA2B,mDAAwB,CAAC,CAAC;QAElG,SAAS,CAAC,+BAA+B;aACtC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,UAAU,CAAC;aACtC,OAAO,CAAC,CAAC,UAAe,EAAE,EAAE;YAC3B,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QAEL,0CAA0C;QAC1C,IAAA,4BAAmB,EAAmB,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,EAAE;YAC/E,MAAM,QAAQ,GAAG,wBAAwB,aAAxB,wBAAwB,uBAAxB,wBAAwB,CAAE,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;YAEzE,MAAM,CAAC,QAAQ,CAAC;gBACd,QAAQ;gBACR,KAAK,EAAE,cAAc,CAAC,KAAK;gBAC3B,MAAM,EAAE,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC;gBAC3C,IAAI,EAAE,cAAc,CAAC,IAAI;gBACzB,OAAO,EAAE,cAAc,CAAC,OAAO;aAChC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,6BAA6B;QAC7B,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAgB,EAAE,EAAE;YACpC,MAAM,aAAa,GAAG,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAuB,CAAC;YAExE,0BAA0B;YAC1B,IAAI,CAAC,aAAa,EAAE;gBAClB,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;aAC7E;YAED,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,WAAW,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AA/CD,kCA+CC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {GlobalProviders, InjectorService, ProviderType} from \"@tsed/di\";\nimport {getOperationsRoutes, OperationMethods} from \"@tsed/schema\";\nimport {ControllerProvider} from \"../domain/ControllerProvider\";\nimport {PlatformRouter} from \"../services/PlatformRouter\";\nimport {EndpointMetadata} from \"../domain/EndpointMetadata\";\nimport {PlatformMiddlewaresChain} from \"../services/PlatformMiddlewaresChain\";\n\nGlobalProviders.createRegistry(ProviderType.CONTROLLER, ControllerProvider, {\n onInvoke(provider: ControllerProvider, locals: any, {injector}) {\n const router = createRouter(injector, provider);\n locals.set(PlatformRouter, router);\n }\n});\n\n/**\n * @ignore\n */\nfunction formatMethod(method: string | undefined) {\n return (method === OperationMethods.CUSTOM ? \"use\" : method || \"use\").toLowerCase();\n}\n\n/**\n * @ignore\n */\nexport function getRouter(injector: InjectorService, provider: ControllerProvider) {\n return injector.get(provider.tokenRouter)!;\n}\n\n/**\n * @ignore\n */\nexport function createRouter(injector: InjectorService, provider: ControllerProvider): PlatformRouter {\n const token = provider.tokenRouter;\n\n if (injector.has(token)) {\n return getRouter(injector, provider);\n }\n\n const router = PlatformRouter.create(injector, provider.routerOptions);\n\n return injector\n .add(token, {\n useValue: router\n })\n .invoke<PlatformRouter>(token);\n}\n\n/**\n * @ignore\n * @param injector\n * @param provider\n */\nexport function buildRouter(injector: InjectorService, provider: ControllerProvider) {\n const {\n middlewares: {useBefore},\n children\n } = provider;\n\n // Controller lifecycle\n const router = createRouter(injector, provider);\n\n if (!router.isBuilt) {\n router.isBuilt = true;\n\n const platformMiddlewaresChain = injector.get<PlatformMiddlewaresChain>(PlatformMiddlewaresChain);\n\n useBefore // Controller before-middleware\n .filter((o) => typeof o === \"function\")\n .forEach((middleware: any) => {\n router.use(middleware);\n });\n\n // build all endpoints and his middlewares\n getOperationsRoutes<EndpointMetadata>(provider.token).forEach((operationRoute) => {\n const handlers = platformMiddlewaresChain?.get(provider, operationRoute);\n\n router.addRoute({\n handlers,\n token: operationRoute.token,\n method: formatMethod(operationRoute.method),\n path: operationRoute.path,\n isFinal: operationRoute.isFinal\n });\n });\n\n // build children controllers\n children.forEach((child: Type<any>) => {\n const childProvider = injector.getProvider(child) as ControllerProvider;\n\n /* istanbul ignore next */\n if (!childProvider) {\n throw new Error(\"Controller component not found in the ControllerRegistry\");\n }\n\n router.use(childProvider.path, buildRouter(injector, childProvider));\n });\n }\n\n return router;\n}\n"]}
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- (0, tslib_1.__exportStar)(require("./interfaces"), exports);
5
- (0, tslib_1.__exportStar)(require("./services/PlatformConfiguration"), exports);
6
- (0, tslib_1.__exportStar)(require("./services/PlatformConfiguration"), exports);
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":";;;AAAA,4DAA6B;AAC7B,gFAAiD;AACjD,gFAAiD","sourcesContent":["export * from \"./interfaces\";\nexport * from \"./services/PlatformConfiguration\";\nexport * from \"./services/PlatformConfiguration\";\n"]}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=EndpointDirectoriesSettings.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EndpointDirectoriesSettings.js","sourceRoot":"","sources":["../../../../src/config/interfaces/EndpointDirectoriesSettings.ts"],"names":[],"mappings":"","sourcesContent":["export interface EndpointDirectoriesSettings {\n [endpoint: string]: any | string | (any | string)[];\n}\n"]}
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- (0, tslib_1.__exportStar)(require("./PlatformLoggerSettings"), exports);
5
- (0, tslib_1.__exportStar)(require("./EndpointDirectoriesSettings"), exports);
6
- (0, tslib_1.__exportStar)(require("./PlatformStaticsSettings"), exports);
7
- (0, tslib_1.__exportStar)(require("./PlatformMulterSettings"), exports);
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/config/interfaces/index.ts"],"names":[],"mappings":";;;AA6FA,wEAAyC;AACzC,6EAA8C;AAC9C,yEAA0C;AAC1C,wEAAyC","sourcesContent":["import {Env} from \"@tsed/core\";\nimport {ConverterSettings} from \"./ConverterSettings\";\nimport {EndpointDirectoriesSettings} from \"./EndpointDirectoriesSettings\";\nimport {PlatformLoggerSettings} from \"./PlatformLoggerSettings\";\nimport {PlatformMulterSettings} from \"./PlatformMulterSettings\";\nimport {PlatformStaticsSettings} from \"./PlatformStaticsSettings\";\nimport type Http from \"http\";\nimport type Https from \"https\";\n\ndeclare global {\n namespace TsED {\n interface LoggerConfiguration extends Partial<PlatformLoggerSettings> {}\n interface Configuration {\n /**\n * The root directory where you build run project. By default, it's equal to `process.cwd().\n */\n rootDir: string;\n /**\n * The environment profile. By default the environment profile is equals to `NODE_ENV`.\n */\n env: Env;\n /**\n * Port number for the [HTTP.Server](https://nodejs.org/api/http.html#http_class_http_server).\n */\n port: string | number;\n /**\n * Port number for the [HTTP.Server](https://nodejs.org/api/http.html#http_class_http_server).\n */\n httpPort: string | number | boolean;\n /**\n * [Https.ServerOptions](https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener)):\n * - `key` &lt;string&gt; | &lt;string[]&gt; | [&lt;Buffer&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer) | &lt;Object[]&gt;: The private key of the server in PEM format. To support multiple keys using different algorithms an array can be provided either as a plain array of key strings or an array of objects in the format `{pem: key, passphrase: passphrase}`. This option is required for ciphers that make use of private keys.\n * - `passphrase` &lt;string&gt; A string containing the passphrase for the private key or pfx.\n * - `cert` &lt;string&gt; | &lt;string[]&gt; | [&lt;Buffer&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer) | [&lt;Buffer[]&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer): A string, Buffer, array of strings, or array of Buffers containing the certificate key of the server in PEM format. (Required)\n * - `ca` &lt;string&gt; | &lt;string[]&gt; | [&lt;Buffer&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer) | [&lt;Buffer[]&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer): A string, Buffer, array of strings, or array of Buffers of trusted certificates in PEM format. If this is omitted several well known \"root\" CAs (like VeriSign) will be used. These are used to authorize connections.\n */\n httpOptions: Http.ServerOptions;\n /**\n * Port number for the [HTTPs.Server](https://nodejs.org/api/https.html#https_class_https_server).\n */\n httpsPort: string | number | boolean;\n /**\n * [Https.ServerOptions](https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener)):\n * - `key` &lt;string&gt; | &lt;string[]&gt; | [&lt;Buffer&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer) | &lt;Object[]&gt;: The private key of the server in PEM format. To support multiple keys using different algorithms an array can be provided either as a plain array of key strings or an array of objects in the format `{pem: key, passphrase: passphrase}`. This option is required for ciphers that make use of private keys.\n * - `passphrase` &lt;string&gt; A string containing the passphrase for the private key or pfx.\n * - `cert` &lt;string&gt; | &lt;string[]&gt; | [&lt;Buffer&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer) | [&lt;Buffer[]&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer): A string, Buffer, array of strings, or array of Buffers containing the certificate key of the server in PEM format. (Required)\n * - `ca` &lt;string&gt; | &lt;string[]&gt; | [&lt;Buffer&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer) | [&lt;Buffer[]&gt;](https://nodejs.org/api/buffer.html#buffer_class_buffer): A string, Buffer, array of strings, or array of Buffers of trusted certificates in PEM format. If this is omitted several well known \"root\" CAs (like VeriSign) will be used. These are used to authorize connections.\n */\n httpsOptions: Https.ServerOptions;\n /**\n * Mount all controllers under a directories to an endpoint.\n */\n mount: EndpointDirectoriesSettings;\n /**\n * List of directories to scan [Services](/docs/services.md), [Middlewares](/docs/middlewares.md) or [Converters](/docs/converters.md).\n */\n componentsScan: (string | RegExp)[];\n /**\n * Disable the glob pattern. In v7 the componentsScan options will be removed in favor of external module loader.\n */\n disableComponentsScan: boolean;\n /**\n * List of glob patterns. Exclude all files which matching with this list when Server scan all components with the `mount` or `scanComponents` options.\n */\n exclude: string[];\n /**\n * Configure the mimes accepted by default by the server.\n */\n acceptMimes: string[];\n /**\n * Enable debug mode. By default debug is false.\n */\n debug: boolean;\n /**\n * Converter configuration.\n */\n converter: Partial<ConverterSettings>;\n /**\n * Logger configuration.\n */\n logger?: LoggerConfiguration;\n /**\n * Object to mount all directories under to his endpoints. See more on [Serve Static](/tutorials/serve-static-files.md).\n */\n statics: PlatformStaticsSettings;\n /**\n * Object configure Multer. See more on [Upload file](/tutorials/serve-static-files.md).\n */\n multer: PlatformMulterSettings;\n }\n }\n}\n\nexport * from \"./PlatformLoggerSettings\";\nexport * from \"./EndpointDirectoriesSettings\";\nexport * from \"./PlatformStaticsSettings\";\nexport * from \"./PlatformMulterSettings\";\n"]}
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HttpServer = void 0;
4
- const di_1 = require("@tsed/di");
5
- /**
6
- * Inject the Http.Server instance.
7
- *
8
- * ### Example
9
- *
10
- * ```typescript
11
- * import {HttpServer, Service} from "@tsed/common";
12
- *
13
- * @Service()
14
- * export default class OtherService {
15
- * constructor(@HttpServer httpServer: HttpServer) {}
16
- * }
17
- * ```
18
- *
19
- * > Note: TypeScript transform and store `HttpServer` as `Function` type in the metadata. So to inject a factory, you must use the `@Inject(type)` decorator.
20
- *
21
- * @param {Type<any>} target
22
- * @param {string} targetKey
23
- * @param {TypedPropertyDescriptor<Function> | number} descriptor
24
- * @returns {any}
25
- * @decorator
26
- * @deprecated Use Https.Server from "http"
27
- */
28
- function HttpServer(target, targetKey, descriptor) {
29
- return (0, di_1.Inject)(HttpServer)(target, targetKey, descriptor);
30
- }
31
- exports.HttpServer = HttpServer;
32
- //# sourceMappingURL=httpServer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"httpServer.js","sourceRoot":"","sources":["../../../src/decorators/httpServer.ts"],"names":[],"mappings":";;;AACA,iCAAgC;AAGhC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,UAAU,CAAC,MAAiB,EAAE,SAAiB,EAAE,UAAsD;IACrH,OAAO,IAAA,WAAM,EAAC,UAAU,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AAC3D,CAAC;AAFD,gCAEC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {Inject} from \"@tsed/di\";\nimport Http from \"http\";\n\n/**\n * Inject the Http.Server instance.\n *\n * ### Example\n *\n * ```typescript\n * import {HttpServer, Service} from \"@tsed/common\";\n *\n * @Service()\n * export default class OtherService {\n * constructor(@HttpServer httpServer: HttpServer) {}\n * }\n * ```\n *\n * > Note: TypeScript transform and store `HttpServer` as `Function` type in the metadata. So to inject a factory, you must use the `@Inject(type)` decorator.\n *\n * @param {Type<any>} target\n * @param {string} targetKey\n * @param {TypedPropertyDescriptor<Function> | number} descriptor\n * @returns {any}\n * @decorator\n * @deprecated Use Https.Server from \"http\"\n */\nexport function HttpServer(target: Type<any>, targetKey: string, descriptor: TypedPropertyDescriptor<Function> | number) {\n return Inject(HttpServer)(target, targetKey, descriptor);\n}\n\nexport type HttpServer = Http.Server;\n"]}
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HttpsServer = void 0;
4
- const di_1 = require("@tsed/di");
5
- /**
6
- * Inject the Https.Server instance.
7
- *
8
- * ### Example
9
- *
10
- * ```typescript
11
- * import {HttpsServer, Service} from "@tsed/common";
12
- *
13
- * @Service()
14
- * export default class OtherService {
15
- * constructor(@HttpsServer httpServer: HttpServer) {}
16
- * }
17
- * ```
18
- *
19
- * > Note: TypeScript transform and store `HttpsServer` as `Function` type in the metadata. So to inject a factory, you must use the `@Inject(type)` decorator.
20
- *
21
- * @param {Type<any>} target
22
- * @param {string} targetKey
23
- * @param {TypedPropertyDescriptor<Function> | number} descriptor
24
- * @returns {any}
25
- * @decorator
26
- * @deprecated Use Https.Server from "https"
27
- */
28
- function HttpsServer(target, targetKey, descriptor) {
29
- return (0, di_1.Inject)(HttpsServer)(target, targetKey, descriptor);
30
- }
31
- exports.HttpsServer = HttpsServer;
32
- //# sourceMappingURL=httpsServer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"httpsServer.js","sourceRoot":"","sources":["../../../src/decorators/httpsServer.ts"],"names":[],"mappings":";;;AACA,iCAAgC;AAGhC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,WAAW,CAAC,MAAiB,EAAE,SAAiB,EAAE,UAAsD;IACtH,OAAO,IAAA,WAAM,EAAC,WAAW,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AAC5D,CAAC;AAFD,kCAEC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {Inject} from \"@tsed/di\";\nimport Https from \"https\";\n\n/**\n * Inject the Https.Server instance.\n *\n * ### Example\n *\n * ```typescript\n * import {HttpsServer, Service} from \"@tsed/common\";\n *\n * @Service()\n * export default class OtherService {\n * constructor(@HttpsServer httpServer: HttpServer) {}\n * }\n * ```\n *\n * > Note: TypeScript transform and store `HttpsServer` as `Function` type in the metadata. So to inject a factory, you must use the `@Inject(type)` decorator.\n *\n * @param {Type<any>} target\n * @param {string} targetKey\n * @param {TypedPropertyDescriptor<Function> | number} descriptor\n * @returns {any}\n * @decorator\n * @deprecated Use Https.Server from \"https\"\n */\nexport function HttpsServer(target: Type<any>, targetKey: string, descriptor: TypedPropertyDescriptor<Function> | number) {\n return Inject(HttpsServer)(target, targetKey, descriptor);\n}\n\nexport type HttpsServer = Https.Server;\n"]}
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- (0, tslib_1.__exportStar)(require("./httpServer"), exports);
5
- (0, tslib_1.__exportStar)(require("./httpsServer"), exports);
6
- (0, tslib_1.__exportStar)(require("./multer"), exports);
7
- // Method
8
- (0, tslib_1.__exportStar)(require("./method/route"), exports);
9
- (0, tslib_1.__exportStar)(require("./method/acceptMime"), exports);
10
- (0, tslib_1.__exportStar)(require("./method/location"), exports);
11
- (0, tslib_1.__exportStar)(require("./method/redirect"), exports);
12
- (0, tslib_1.__exportStar)(require("./method/endpointFn"), exports);
13
- (0, tslib_1.__exportStar)(require("./method/view"), exports);
14
- // Params
15
- (0, tslib_1.__exportStar)(require("./params/response"), exports);
16
- (0, tslib_1.__exportStar)(require("./params/request"), exports);
17
- (0, tslib_1.__exportStar)(require("./params/next"), exports);
18
- (0, tslib_1.__exportStar)(require("./params/error"), exports);
19
- // utils
20
- (0, tslib_1.__exportStar)(require("../utils/mapReturnedResponse"), exports);
21
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decorators/index.ts"],"names":[],"mappings":";;;AAAA,4DAA6B;AAC7B,6DAA8B;AAE9B,wDAAyB;AAEzB,SAAS;AACT,8DAA+B;AAC/B,mEAAoC;AACpC,iEAAkC;AAClC,iEAAkC;AAClC,mEAAoC;AACpC,6DAA8B;AAE9B,SAAS;AACT,iEAAkC;AAClC,gEAAiC;AACjC,6DAA8B;AAC9B,8DAA+B;AAE/B,QAAQ;AACR,4EAA6C","sourcesContent":["export * from \"./httpServer\";\nexport * from \"./httpsServer\";\n\nexport * from \"./multer\";\n\n// Method\nexport * from \"./method/route\";\nexport * from \"./method/acceptMime\";\nexport * from \"./method/location\";\nexport * from \"./method/redirect\";\nexport * from \"./method/endpointFn\";\nexport * from \"./method/view\";\n\n// Params\nexport * from \"./params/response\";\nexport * from \"./params/request\";\nexport * from \"./params/next\";\nexport * from \"./params/error\";\n\n// utils\nexport * from \"../utils/mapReturnedResponse\";\n"]}