@forklaunch/core 0.2.6 → 0.2.7

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 (384) hide show
  1. package/lib/jest.config.d.ts.map +1 -1
  2. package/lib/jest.config.js +0 -2
  3. package/lib/src/http/guards/isForklaunchRouter.d.ts +4 -0
  4. package/lib/src/http/guards/isForklaunchRouter.d.ts.map +1 -0
  5. package/lib/src/http/guards/isForklaunchRouter.js +7 -0
  6. package/lib/src/http/guards/isTypedHandler.d.ts +1 -1
  7. package/lib/src/http/guards/isTypedHandler.d.ts.map +1 -1
  8. package/lib/src/http/handlers/typedAuthHandler.d.ts +5 -0
  9. package/lib/src/http/handlers/typedAuthHandler.d.ts.map +1 -0
  10. package/lib/src/http/handlers/typedAuthHandler.js +3 -0
  11. package/lib/src/http/handlers/typedHandler.d.ts +0 -6
  12. package/lib/src/http/handlers/typedHandler.d.ts.map +1 -1
  13. package/lib/src/http/index.d.ts +2 -0
  14. package/lib/src/http/index.d.ts.map +1 -1
  15. package/lib/src/http/index.js +2 -0
  16. package/lib/src/http/middleware/request/auth.middleware.d.ts +3 -18
  17. package/lib/src/http/middleware/request/auth.middleware.d.ts.map +1 -1
  18. package/lib/src/http/middleware/request/auth.middleware.js +104 -69
  19. package/lib/src/http/openApiV3Generator/openApiV3Generator.js +1 -1
  20. package/lib/src/http/router/expressLikeRouter.d.ts.map +1 -1
  21. package/lib/src/http/router/expressLikeRouter.js +4 -23
  22. package/lib/src/http/types/apiDefinition.types.d.ts +36 -13
  23. package/lib/src/http/types/apiDefinition.types.d.ts.map +1 -1
  24. package/lib/src/http/types/contractDetails.types.d.ts +53 -11
  25. package/lib/src/http/types/contractDetails.types.d.ts.map +1 -1
  26. package/lib/src/http/types/expressLikeRouter.types.d.ts +1 -1
  27. package/lib/src/http/types/expressLikeRouter.types.d.ts.map +1 -1
  28. package/lib/src/http/types/typedHandler.types.d.ts +10 -0
  29. package/lib/src/http/types/typedHandler.types.d.ts.map +1 -0
  30. package/lib/tests/expressLikeRouterInstantiation.test.js +47 -2
  31. package/lib/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +15 -15
  33. package/LICENSE +0 -21
  34. package/lib/dist/cache/index.d.ts +0 -4
  35. package/lib/dist/cache/index.d.ts.map +0 -1
  36. package/lib/dist/cache/index.js +0 -3
  37. package/lib/dist/cache/interfaces/ttlCache.interface.d.ts +0 -2
  38. package/lib/dist/cache/interfaces/ttlCache.interface.d.ts.map +0 -1
  39. package/lib/dist/cache/redisTtlCache.d.ts +0 -353
  40. package/lib/dist/cache/redisTtlCache.d.ts.map +0 -1
  41. package/lib/dist/cache/redisTtlCache.js +0 -98
  42. package/lib/dist/cache/types/ttlCacheRecord.types.d.ts +0 -2
  43. package/lib/dist/cache/types/ttlCacheRecord.types.d.ts.map +0 -1
  44. package/lib/dist/cache/types/ttlCacheRecord.types.js +0 -1
  45. package/lib/dist/controllers/index.d.ts +0 -2
  46. package/lib/dist/controllers/index.d.ts.map +0 -1
  47. package/lib/dist/controllers/index.js +0 -1
  48. package/lib/dist/controllers/interfaces/controller.interface.d.ts +0 -2
  49. package/lib/dist/controllers/interfaces/controller.interface.d.ts.map +0 -1
  50. package/lib/dist/controllers/interfaces/controller.interface.js +0 -1
  51. package/lib/dist/database/index.d.ts +0 -2
  52. package/lib/dist/database/index.d.ts.map +0 -1
  53. package/lib/dist/database/index.js +0 -1
  54. package/lib/dist/database/mikro/models/entities/base.entity.d.ts +0 -26
  55. package/lib/dist/database/mikro/models/entities/base.entity.d.ts.map +0 -1
  56. package/lib/dist/database/mikro/models/entities/base.entity.js +0 -46
  57. package/lib/dist/entityMapper/index.d.ts +0 -3
  58. package/lib/dist/entityMapper/index.d.ts.map +0 -1
  59. package/lib/dist/entityMapper/index.js +0 -2
  60. package/lib/dist/entityMapper/interfaces/entityMapper.interface.d.ts +0 -2
  61. package/lib/dist/entityMapper/interfaces/entityMapper.interface.d.ts.map +0 -1
  62. package/lib/dist/entityMapper/interfaces/entityMapper.interface.js +0 -1
  63. package/lib/dist/entityMapper/models/baseEntityMapper.model.d.ts +0 -63
  64. package/lib/dist/entityMapper/models/baseEntityMapper.model.d.ts.map +0 -1
  65. package/lib/dist/entityMapper/models/baseEntityMapper.model.js +0 -75
  66. package/lib/dist/entityMapper/models/requestEntityMapper.model.d.ts +0 -58
  67. package/lib/dist/entityMapper/models/requestEntityMapper.model.d.ts.map +0 -1
  68. package/lib/dist/entityMapper/models/requestEntityMapper.model.js +0 -70
  69. package/lib/dist/entityMapper/models/responseEntityMapper.model.d.ts +0 -56
  70. package/lib/dist/entityMapper/models/responseEntityMapper.model.d.ts.map +0 -1
  71. package/lib/dist/entityMapper/models/responseEntityMapper.model.js +0 -65
  72. package/lib/dist/entityMapper/types/entityMapper.types.d.ts +0 -2
  73. package/lib/dist/entityMapper/types/entityMapper.types.d.ts.map +0 -1
  74. package/lib/dist/entityMapper/types/entityMapper.types.js +0 -1
  75. package/lib/dist/http/guards/isHttpContractDetails.d.ts +0 -5
  76. package/lib/dist/http/guards/isHttpContractDetails.d.ts.map +0 -1
  77. package/lib/dist/http/guards/isHttpContractDetails.js +0 -6
  78. package/lib/dist/http/guards/isResponseShape.d.ts +0 -2
  79. package/lib/dist/http/guards/isResponseShape.d.ts.map +0 -1
  80. package/lib/dist/http/guards/isResponseShape.js +0 -7
  81. package/lib/dist/http/index.d.ts +0 -6
  82. package/lib/dist/http/index.d.ts.map +0 -1
  83. package/lib/dist/http/index.js +0 -5
  84. package/lib/dist/http/interfaces/expressLikeApplication.interface.d.ts +0 -12
  85. package/lib/dist/http/interfaces/expressLikeApplication.interface.d.ts.map +0 -1
  86. package/lib/dist/http/interfaces/expressLikeApplication.interface.js +0 -14
  87. package/lib/dist/http/interfaces/expressLikeRouter.interface.d.ts +0 -103
  88. package/lib/dist/http/interfaces/expressLikeRouter.interface.d.ts.map +0 -1
  89. package/lib/dist/http/interfaces/expressLikeRouter.interface.js +0 -336
  90. package/lib/dist/http/interfaces/index.d.ts +0 -3
  91. package/lib/dist/http/interfaces/index.d.ts.map +0 -1
  92. package/lib/dist/http/interfaces/index.js +0 -2
  93. package/lib/dist/http/middleware/index.d.ts +0 -3
  94. package/lib/dist/http/middleware/index.d.ts.map +0 -1
  95. package/lib/dist/http/middleware/index.js +0 -2
  96. package/lib/dist/http/middleware/request.middleware.d.ts +0 -69
  97. package/lib/dist/http/middleware/request.middleware.d.ts.map +0 -1
  98. package/lib/dist/http/middleware/request.middleware.js +0 -210
  99. package/lib/dist/http/middleware/response.middleware.d.ts +0 -27
  100. package/lib/dist/http/middleware/response.middleware.d.ts.map +0 -1
  101. package/lib/dist/http/middleware/response.middleware.js +0 -52
  102. package/lib/dist/http/openApiV3Generator/index.d.ts +0 -2
  103. package/lib/dist/http/openApiV3Generator/index.d.ts.map +0 -1
  104. package/lib/dist/http/openApiV3Generator/index.js +0 -1
  105. package/lib/dist/http/openApiV3Generator/openApiV3Generator.d.ts +0 -11
  106. package/lib/dist/http/openApiV3Generator/openApiV3Generator.d.ts.map +0 -1
  107. package/lib/dist/http/openApiV3Generator/openApiV3Generator.js +0 -167
  108. package/lib/dist/http/types/apiDefinition.types.d.ts +0 -2
  109. package/lib/dist/http/types/apiDefinition.types.d.ts.map +0 -1
  110. package/lib/dist/http/types/apiDefinition.types.js +0 -1
  111. package/lib/dist/http/types/contractDetails.types.d.ts +0 -2
  112. package/lib/dist/http/types/contractDetails.types.d.ts.map +0 -1
  113. package/lib/dist/http/types/contractDetails.types.js +0 -1
  114. package/lib/dist/http/types/index.d.ts +0 -4
  115. package/lib/dist/http/types/index.d.ts.map +0 -1
  116. package/lib/dist/http/types/index.js +0 -3
  117. package/lib/dist/http/types/router.types.d.ts +0 -2
  118. package/lib/dist/http/types/router.types.d.ts.map +0 -1
  119. package/lib/dist/http/types/router.types.js +0 -1
  120. package/lib/dist/http/utils/enrichExpressLikeSend.d.ts +0 -28
  121. package/lib/dist/http/utils/enrichExpressLikeSend.d.ts.map +0 -1
  122. package/lib/dist/http/utils/enrichExpressLikeSend.js +0 -50
  123. package/lib/dist/http/utils/httpStatusCodes.d.ts +0 -986
  124. package/lib/dist/http/utils/httpStatusCodes.d.ts.map +0 -1
  125. package/lib/dist/http/utils/httpStatusCodes.js +0 -1039
  126. package/lib/dist/http/utils/index.d.ts +0 -3
  127. package/lib/dist/http/utils/index.d.ts.map +0 -1
  128. package/lib/dist/http/utils/index.js +0 -2
  129. package/lib/dist/index.d.ts +0 -7
  130. package/lib/dist/index.d.ts.map +0 -1
  131. package/lib/dist/index.js +0 -6
  132. package/lib/dist/jest.config.d.ts +0 -15
  133. package/lib/dist/jest.config.d.ts.map +0 -1
  134. package/lib/dist/jest.config.js +0 -21
  135. package/lib/dist/lib/index.d.ts +0 -7
  136. package/lib/dist/lib/index.d.ts.map +0 -1
  137. package/lib/dist/lib/index.js +0 -6
  138. package/lib/dist/lib/jest.config.d.ts +0 -15
  139. package/lib/dist/lib/jest.config.d.ts.map +0 -1
  140. package/lib/dist/lib/jest.config.js +0 -21
  141. package/lib/dist/lib/src/cache/index.d.ts +0 -4
  142. package/lib/dist/lib/src/cache/index.d.ts.map +0 -1
  143. package/lib/dist/lib/src/cache/index.js +0 -3
  144. package/lib/dist/lib/src/cache/interfaces/ttlCache.interface.d.ts +0 -2
  145. package/lib/dist/lib/src/cache/interfaces/ttlCache.interface.d.ts.map +0 -1
  146. package/lib/dist/lib/src/cache/interfaces/ttlCache.interface.js +0 -1
  147. package/lib/dist/lib/src/cache/redisTtlCache.d.ts +0 -353
  148. package/lib/dist/lib/src/cache/redisTtlCache.d.ts.map +0 -1
  149. package/lib/dist/lib/src/cache/redisTtlCache.js +0 -98
  150. package/lib/dist/lib/src/cache/types/ttlCacheRecord.types.d.ts +0 -2
  151. package/lib/dist/lib/src/cache/types/ttlCacheRecord.types.d.ts.map +0 -1
  152. package/lib/dist/lib/src/cache/types/ttlCacheRecord.types.js +0 -1
  153. package/lib/dist/lib/src/controllers/index.d.ts +0 -2
  154. package/lib/dist/lib/src/controllers/index.d.ts.map +0 -1
  155. package/lib/dist/lib/src/controllers/index.js +0 -1
  156. package/lib/dist/lib/src/controllers/interfaces/controller.interface.d.ts +0 -2
  157. package/lib/dist/lib/src/controllers/interfaces/controller.interface.d.ts.map +0 -1
  158. package/lib/dist/lib/src/controllers/interfaces/controller.interface.js +0 -1
  159. package/lib/dist/lib/src/database/index.d.ts +0 -2
  160. package/lib/dist/lib/src/database/index.d.ts.map +0 -1
  161. package/lib/dist/lib/src/database/index.js +0 -1
  162. package/lib/dist/lib/src/database/mikro/models/entities/base.entity.d.ts +0 -26
  163. package/lib/dist/lib/src/database/mikro/models/entities/base.entity.d.ts.map +0 -1
  164. package/lib/dist/lib/src/database/mikro/models/entities/base.entity.js +0 -46
  165. package/lib/dist/lib/src/domainMapper/index.d.ts +0 -3
  166. package/lib/dist/lib/src/domainMapper/index.d.ts.map +0 -1
  167. package/lib/dist/lib/src/domainMapper/index.js +0 -2
  168. package/lib/dist/lib/src/domainMapper/interfaces/dtoMapper.interface.d.ts +0 -2
  169. package/lib/dist/lib/src/domainMapper/interfaces/dtoMapper.interface.d.ts.map +0 -1
  170. package/lib/dist/lib/src/domainMapper/interfaces/dtoMapper.interface.js +0 -1
  171. package/lib/dist/lib/src/domainMapper/models/baseDtoMapper.model.d.ts +0 -63
  172. package/lib/dist/lib/src/domainMapper/models/baseDtoMapper.model.d.ts.map +0 -1
  173. package/lib/dist/lib/src/domainMapper/models/baseDtoMapper.model.js +0 -75
  174. package/lib/dist/lib/src/domainMapper/models/requestDtoMapper.model.d.ts +0 -58
  175. package/lib/dist/lib/src/domainMapper/models/requestDtoMapper.model.d.ts.map +0 -1
  176. package/lib/dist/lib/src/domainMapper/models/requestDtoMapper.model.js +0 -70
  177. package/lib/dist/lib/src/domainMapper/models/responseDtoMapper.model.d.ts +0 -56
  178. package/lib/dist/lib/src/domainMapper/models/responseDtoMapper.model.d.ts.map +0 -1
  179. package/lib/dist/lib/src/domainMapper/models/responseDtoMapper.model.js +0 -65
  180. package/lib/dist/lib/src/domainMapper/types/dtoMapper.types.d.ts +0 -2
  181. package/lib/dist/lib/src/domainMapper/types/dtoMapper.types.d.ts.map +0 -1
  182. package/lib/dist/lib/src/domainMapper/types/dtoMapper.types.js +0 -1
  183. package/lib/dist/lib/src/dtoMapper/index.d.ts +0 -3
  184. package/lib/dist/lib/src/dtoMapper/index.d.ts.map +0 -1
  185. package/lib/dist/lib/src/dtoMapper/index.js +0 -2
  186. package/lib/dist/lib/src/dtoMapper/interfaces/dtoMapper.interface.d.ts +0 -2
  187. package/lib/dist/lib/src/dtoMapper/interfaces/dtoMapper.interface.d.ts.map +0 -1
  188. package/lib/dist/lib/src/dtoMapper/interfaces/dtoMapper.interface.js +0 -1
  189. package/lib/dist/lib/src/dtoMapper/models/baseDtoMapper.model.d.ts +0 -63
  190. package/lib/dist/lib/src/dtoMapper/models/baseDtoMapper.model.d.ts.map +0 -1
  191. package/lib/dist/lib/src/dtoMapper/models/baseDtoMapper.model.js +0 -75
  192. package/lib/dist/lib/src/dtoMapper/models/requestDtoMapper.model.d.ts +0 -58
  193. package/lib/dist/lib/src/dtoMapper/models/requestDtoMapper.model.d.ts.map +0 -1
  194. package/lib/dist/lib/src/dtoMapper/models/requestDtoMapper.model.js +0 -70
  195. package/lib/dist/lib/src/dtoMapper/models/responseDtoMapper.model.d.ts +0 -56
  196. package/lib/dist/lib/src/dtoMapper/models/responseDtoMapper.model.d.ts.map +0 -1
  197. package/lib/dist/lib/src/dtoMapper/models/responseDtoMapper.model.js +0 -65
  198. package/lib/dist/lib/src/dtoMapper/types/dtoMapper.types.d.ts +0 -2
  199. package/lib/dist/lib/src/dtoMapper/types/dtoMapper.types.d.ts.map +0 -1
  200. package/lib/dist/lib/src/dtoMapper/types/dtoMapper.types.js +0 -1
  201. package/lib/dist/lib/src/http/application/expressLikeApplication.d.ts +0 -18
  202. package/lib/dist/lib/src/http/application/expressLikeApplication.d.ts.map +0 -1
  203. package/lib/dist/lib/src/http/application/expressLikeApplication.js +0 -20
  204. package/lib/dist/lib/src/http/guards/isHttpContractDetails.d.ts +0 -5
  205. package/lib/dist/lib/src/http/guards/isHttpContractDetails.d.ts.map +0 -1
  206. package/lib/dist/lib/src/http/guards/isHttpContractDetails.js +0 -6
  207. package/lib/dist/lib/src/http/guards/isResponseShape.d.ts +0 -2
  208. package/lib/dist/lib/src/http/guards/isResponseShape.d.ts.map +0 -1
  209. package/lib/dist/lib/src/http/guards/isResponseShape.js +0 -7
  210. package/lib/dist/lib/src/http/handler/typedHandler.d.ts +0 -21
  211. package/lib/dist/lib/src/http/handler/typedHandler.d.ts.map +0 -1
  212. package/lib/dist/lib/src/http/handler/typedHandler.js +0 -25
  213. package/lib/dist/lib/src/http/index.d.ts +0 -11
  214. package/lib/dist/lib/src/http/index.d.ts.map +0 -1
  215. package/lib/dist/lib/src/http/index.js +0 -10
  216. package/lib/dist/lib/src/http/interfaces/expressLikeApplication.interface.d.ts +0 -12
  217. package/lib/dist/lib/src/http/interfaces/expressLikeApplication.interface.d.ts.map +0 -1
  218. package/lib/dist/lib/src/http/interfaces/expressLikeApplication.interface.js +0 -14
  219. package/lib/dist/lib/src/http/interfaces/expressLikeRouter.interface.d.ts +0 -2
  220. package/lib/dist/lib/src/http/interfaces/expressLikeRouter.interface.d.ts.map +0 -1
  221. package/lib/dist/lib/src/http/interfaces/expressLikeRouter.interface.js +0 -1
  222. package/lib/dist/lib/src/http/interfaces/index.d.ts +0 -3
  223. package/lib/dist/lib/src/http/interfaces/index.d.ts.map +0 -1
  224. package/lib/dist/lib/src/http/interfaces/index.js +0 -2
  225. package/lib/dist/lib/src/http/middleware/index.d.ts +0 -3
  226. package/lib/dist/lib/src/http/middleware/index.d.ts.map +0 -1
  227. package/lib/dist/lib/src/http/middleware/index.js +0 -2
  228. package/lib/dist/lib/src/http/middleware/request/auth.middleware.d.ts +0 -27
  229. package/lib/dist/lib/src/http/middleware/request/auth.middleware.d.ts.map +0 -1
  230. package/lib/dist/lib/src/http/middleware/request/auth.middleware.js +0 -107
  231. package/lib/dist/lib/src/http/middleware/request/cors.middleware.d.ts +0 -9
  232. package/lib/dist/lib/src/http/middleware/request/cors.middleware.d.ts.map +0 -1
  233. package/lib/dist/lib/src/http/middleware/request/cors.middleware.js +0 -15
  234. package/lib/dist/lib/src/http/middleware/request/createContext.middleware.d.ts +0 -12
  235. package/lib/dist/lib/src/http/middleware/request/createContext.middleware.d.ts.map +0 -1
  236. package/lib/dist/lib/src/http/middleware/request/createContext.middleware.js +0 -26
  237. package/lib/dist/lib/src/http/middleware/request/enrichDetails.middleware.d.ts +0 -12
  238. package/lib/dist/lib/src/http/middleware/request/enrichDetails.middleware.d.ts.map +0 -1
  239. package/lib/dist/lib/src/http/middleware/request/enrichDetails.middleware.js +0 -19
  240. package/lib/dist/lib/src/http/middleware/request/parse.middleware.d.ts +0 -13
  241. package/lib/dist/lib/src/http/middleware/request/parse.middleware.d.ts.map +0 -1
  242. package/lib/dist/lib/src/http/middleware/request/parse.middleware.js +0 -43
  243. package/lib/dist/lib/src/http/middleware/request.middleware.d.ts +0 -69
  244. package/lib/dist/lib/src/http/middleware/request.middleware.d.ts.map +0 -1
  245. package/lib/dist/lib/src/http/middleware/request.middleware.js +0 -210
  246. package/lib/dist/lib/src/http/middleware/response/parse.middleware.d.ts +0 -27
  247. package/lib/dist/lib/src/http/middleware/response/parse.middleware.d.ts.map +0 -1
  248. package/lib/dist/lib/src/http/middleware/response/parse.middleware.js +0 -52
  249. package/lib/dist/lib/src/http/middleware/response.middleware.d.ts +0 -27
  250. package/lib/dist/lib/src/http/middleware/response.middleware.d.ts.map +0 -1
  251. package/lib/dist/lib/src/http/middleware/response.middleware.js +0 -52
  252. package/lib/dist/lib/src/http/openApiV3Generator/index.d.ts +0 -2
  253. package/lib/dist/lib/src/http/openApiV3Generator/index.d.ts.map +0 -1
  254. package/lib/dist/lib/src/http/openApiV3Generator/index.js +0 -1
  255. package/lib/dist/lib/src/http/openApiV3Generator/openApiV3Generator.d.ts +0 -11
  256. package/lib/dist/lib/src/http/openApiV3Generator/openApiV3Generator.d.ts.map +0 -1
  257. package/lib/dist/lib/src/http/openApiV3Generator/openApiV3Generator.js +0 -167
  258. package/lib/dist/lib/src/http/router/expressLikeRouter.d.ts +0 -89
  259. package/lib/dist/lib/src/http/router/expressLikeRouter.d.ts.map +0 -1
  260. package/lib/dist/lib/src/http/router/expressLikeRouter.js +0 -322
  261. package/lib/dist/lib/src/http/types/apiDefinition.types.d.ts +0 -2
  262. package/lib/dist/lib/src/http/types/apiDefinition.types.d.ts.map +0 -1
  263. package/lib/dist/lib/src/http/types/apiDefinition.types.js +0 -1
  264. package/lib/dist/lib/src/http/types/contractDetails.types.d.ts +0 -2
  265. package/lib/dist/lib/src/http/types/contractDetails.types.d.ts.map +0 -1
  266. package/lib/dist/lib/src/http/types/contractDetails.types.js +0 -1
  267. package/lib/dist/lib/src/http/types/index.d.ts +0 -4
  268. package/lib/dist/lib/src/http/types/index.d.ts.map +0 -1
  269. package/lib/dist/lib/src/http/types/index.js +0 -3
  270. package/lib/dist/lib/src/http/types/router.types.d.ts +0 -2
  271. package/lib/dist/lib/src/http/types/router.types.d.ts.map +0 -1
  272. package/lib/dist/lib/src/http/types/router.types.js +0 -1
  273. package/lib/dist/lib/src/http/utils/enrichExpressLikeSend.d.ts +0 -28
  274. package/lib/dist/lib/src/http/utils/enrichExpressLikeSend.d.ts.map +0 -1
  275. package/lib/dist/lib/src/http/utils/enrichExpressLikeSend.js +0 -50
  276. package/lib/dist/lib/src/http/utils/httpStatusCodes.d.ts +0 -986
  277. package/lib/dist/lib/src/http/utils/httpStatusCodes.d.ts.map +0 -1
  278. package/lib/dist/lib/src/http/utils/httpStatusCodes.js +0 -1039
  279. package/lib/dist/lib/src/http/utils/index.d.ts +0 -3
  280. package/lib/dist/lib/src/http/utils/index.d.ts.map +0 -1
  281. package/lib/dist/lib/src/http/utils/index.js +0 -2
  282. package/lib/dist/lib/src/services/index.d.ts +0 -2
  283. package/lib/dist/lib/src/services/index.d.ts.map +0 -1
  284. package/lib/dist/lib/src/services/index.js +0 -1
  285. package/lib/dist/lib/src/services/interfaces/baseService.d.ts +0 -2
  286. package/lib/dist/lib/src/services/interfaces/baseService.d.ts.map +0 -1
  287. package/lib/dist/lib/src/services/interfaces/baseService.js +0 -1
  288. package/lib/dist/lib/tests/dtoMapper.test.d.ts +0 -2
  289. package/lib/dist/lib/tests/dtoMapper.test.d.ts.map +0 -1
  290. package/lib/dist/lib/tests/dtoMapper.test.js +0 -172
  291. package/lib/dist/lib/tests/entityMapper.test.d.ts +0 -2
  292. package/lib/dist/lib/tests/entityMapper.test.d.ts.map +0 -1
  293. package/lib/dist/lib/tests/entityMapper.test.js +0 -172
  294. package/lib/dist/lib/tests/expressLikeRouter.test.d.ts +0 -2
  295. package/lib/dist/lib/tests/expressLikeRouter.test.d.ts.map +0 -1
  296. package/lib/dist/lib/tests/expressLikeRouter.test.js +0 -3
  297. package/lib/dist/lib/tests/http.middleware.test.d.ts +0 -2
  298. package/lib/dist/lib/tests/http.middleware.test.d.ts.map +0 -1
  299. package/lib/dist/lib/tests/http.middleware.test.js +0 -95
  300. package/lib/dist/lib/tests/openApiV3Generator.test.d.ts +0 -2
  301. package/lib/dist/lib/tests/openApiV3Generator.test.d.ts.map +0 -1
  302. package/lib/dist/lib/tests/openApiV3Generator.test.js +0 -66
  303. package/lib/dist/lib/tests/redisTtlCache.test.d.ts +0 -2
  304. package/lib/dist/lib/tests/redisTtlCache.test.d.ts.map +0 -1
  305. package/lib/dist/lib/tests/redisTtlCache.test.js +0 -49
  306. package/lib/dist/lib/tests/typedHandler.test.d.ts +0 -2
  307. package/lib/dist/lib/tests/typedHandler.test.d.ts.map +0 -1
  308. package/lib/dist/lib/tests/typedHandler.test.js +0 -3
  309. package/lib/dist/lib/vitest.config.d.ts +0 -3
  310. package/lib/dist/lib/vitest.config.d.ts.map +0 -1
  311. package/lib/dist/lib/vitest.config.js +0 -7
  312. package/lib/dist/services/index.d.ts +0 -2
  313. package/lib/dist/services/index.d.ts.map +0 -1
  314. package/lib/dist/services/index.js +0 -1
  315. package/lib/dist/services/interfaces/baseService.d.ts +0 -2
  316. package/lib/dist/services/interfaces/baseService.d.ts.map +0 -1
  317. package/lib/dist/services/interfaces/baseService.js +0 -1
  318. package/lib/dist/tests/entityMapper.test.d.ts +0 -2
  319. package/lib/dist/tests/entityMapper.test.d.ts.map +0 -1
  320. package/lib/dist/tests/entityMapper.test.js +0 -171
  321. package/lib/dist/tests/http.middleware.test.d.ts +0 -2
  322. package/lib/dist/tests/http.middleware.test.d.ts.map +0 -1
  323. package/lib/dist/tests/http.middleware.test.js +0 -93
  324. package/lib/dist/tests/openApiV3Generator.test.d.ts +0 -2
  325. package/lib/dist/tests/openApiV3Generator.test.d.ts.map +0 -1
  326. package/lib/dist/tests/openApiV3Generator.test.js +0 -66
  327. package/lib/dist/tests/redisTtlCache.test.d.ts +0 -2
  328. package/lib/dist/tests/redisTtlCache.test.d.ts.map +0 -1
  329. package/lib/dist/tests/redisTtlCache.test.js +0 -49
  330. package/lib/index.d.ts +0 -7
  331. package/lib/index.d.ts.map +0 -1
  332. package/lib/index.js +0 -7
  333. package/lib/src/domainMapper/index.d.ts +0 -3
  334. package/lib/src/domainMapper/index.d.ts.map +0 -1
  335. package/lib/src/domainMapper/index.js +0 -2
  336. package/lib/src/domainMapper/interfaces/dtoMapper.interface.d.ts +0 -18
  337. package/lib/src/domainMapper/interfaces/dtoMapper.interface.d.ts.map +0 -1
  338. package/lib/src/domainMapper/interfaces/dtoMapper.interface.js +0 -1
  339. package/lib/src/domainMapper/models/baseDtoMapper.model.d.ts +0 -72
  340. package/lib/src/domainMapper/models/baseDtoMapper.model.d.ts.map +0 -1
  341. package/lib/src/domainMapper/models/baseDtoMapper.model.js +0 -75
  342. package/lib/src/domainMapper/models/requestDtoMapper.model.d.ts +0 -68
  343. package/lib/src/domainMapper/models/requestDtoMapper.model.d.ts.map +0 -1
  344. package/lib/src/domainMapper/models/requestDtoMapper.model.js +0 -70
  345. package/lib/src/domainMapper/models/responseDtoMapper.model.d.ts +0 -67
  346. package/lib/src/domainMapper/models/responseDtoMapper.model.d.ts.map +0 -1
  347. package/lib/src/domainMapper/models/responseDtoMapper.model.js +0 -65
  348. package/lib/src/domainMapper/types/dtoMapper.types.d.ts +0 -9
  349. package/lib/src/domainMapper/types/dtoMapper.types.d.ts.map +0 -1
  350. package/lib/src/domainMapper/types/dtoMapper.types.js +0 -1
  351. package/lib/src/http/handler/typedHandler.d.ts +0 -24
  352. package/lib/src/http/handler/typedHandler.d.ts.map +0 -1
  353. package/lib/src/http/handler/typedHandler.js +0 -25
  354. package/lib/src/http/interfaces/expressLikeApplication.interface.d.ts +0 -16
  355. package/lib/src/http/interfaces/expressLikeApplication.interface.d.ts.map +0 -1
  356. package/lib/src/http/interfaces/expressLikeApplication.interface.js +0 -14
  357. package/lib/src/http/interfaces/index.d.ts +0 -3
  358. package/lib/src/http/interfaces/index.d.ts.map +0 -1
  359. package/lib/src/http/interfaces/index.js +0 -2
  360. package/lib/src/http/middleware/index.d.ts +0 -3
  361. package/lib/src/http/middleware/index.d.ts.map +0 -1
  362. package/lib/src/http/middleware/index.js +0 -2
  363. package/lib/src/http/middleware/request.middleware.d.ts +0 -73
  364. package/lib/src/http/middleware/request.middleware.d.ts.map +0 -1
  365. package/lib/src/http/middleware/request.middleware.js +0 -210
  366. package/lib/src/http/middleware/response.middleware.d.ts +0 -31
  367. package/lib/src/http/middleware/response.middleware.d.ts.map +0 -1
  368. package/lib/src/http/middleware/response.middleware.js +0 -52
  369. package/lib/src/http/openApiV3Generator/index.d.ts +0 -2
  370. package/lib/src/http/openApiV3Generator/index.d.ts.map +0 -1
  371. package/lib/src/http/openApiV3Generator/index.js +0 -1
  372. package/lib/src/http/types/index.d.ts +0 -4
  373. package/lib/src/http/types/index.d.ts.map +0 -1
  374. package/lib/src/http/types/index.js +0 -3
  375. package/lib/src/http/utils/index.d.ts +0 -3
  376. package/lib/src/http/utils/index.d.ts.map +0 -1
  377. package/lib/src/http/utils/index.js +0 -2
  378. package/lib/tests/entityMapper.test.d.ts +0 -2
  379. package/lib/tests/entityMapper.test.d.ts.map +0 -1
  380. package/lib/tests/entityMapper.test.js +0 -168
  381. package/lib/tests/expressLikeRouter.test.d.ts +0 -2
  382. package/lib/tests/expressLikeRouter.test.d.ts.map +0 -1
  383. package/lib/tests/expressLikeRouter.test.js +0 -3
  384. /package/lib/{dist/cache/interfaces/ttlCache.interface.js → src/http/types/typedHandler.types.js} +0 -0
@@ -1,210 +0,0 @@
1
- import cors from 'cors';
2
- import * as jose from 'jose';
3
- import { v4 } from 'uuid';
4
- import { isResponseShape } from '../guards/isResponseShape';
5
- /**
6
- * Cors middleware handler
7
- *
8
- * @param req - Express-like request object
9
- * @param res - Express-like response object
10
- * @param next - Express-like next function
11
- */
12
- export function corsMiddleware(req, res, next) {
13
- console.debug('[MIDDLEWARE] cors started');
14
- if (req.method === 'OPTIONS') {
15
- res.cors = true;
16
- }
17
- cors()(req, res, next ?? (() => { }));
18
- }
19
- /**
20
- * Middleware to create and add a request context.
21
- *
22
- * @template SV - A type that extends AnySchemaValidator.
23
- * @template Request - A type that extends ForklaunchRequest.
24
- * @template Response - A type that extends ForklaunchResponse.
25
- * @template NextFunction - A type that extends ForklaunchNextFunction.
26
- * @param {SV} schemaValidator - The schema validator.
27
- * @returns {Function} - Middleware function to create request context.
28
- */
29
- export function createRequestContext(schemaValidator) {
30
- return (req, res, next) => {
31
- console.debug('[MIDDLEWARE] createRequestContext started');
32
- req.schemaValidator = schemaValidator;
33
- let correlationId = v4();
34
- if (req.headers['x-correlation-id']) {
35
- correlationId = req.headers['x-correlation-id'];
36
- }
37
- res.setHeader('x-correlation-id', correlationId);
38
- req.context = {
39
- correlationId: correlationId
40
- };
41
- next?.();
42
- };
43
- }
44
- /**
45
- * Middleware to enrich the request details with contract details.
46
- *
47
- * @template SV - A type that extends AnySchemaValidator.
48
- * @template Request - A type that extends ForklaunchRequest.
49
- * @template Response - A type that extends ForklaunchResponse.
50
- * @template NextFunction - A type that extends ForklaunchNextFunction.
51
- * @param {PathParamHttpContractDetails<SV> | HttpContractDetails<SV>} contractDetails - The contract details.
52
- * @returns {Function} - Middleware function to enrich request details.
53
- */
54
- export function enrichRequestDetails(contractDetails, requestSchema, responseSchemas) {
55
- return (req, res, next) => {
56
- console.debug('[MIDDLEWARE] enrichRequestDetails started');
57
- req.contractDetails = contractDetails;
58
- req.requestSchema = requestSchema;
59
- res.responseSchemas = responseSchemas;
60
- next?.();
61
- };
62
- }
63
- /**
64
- * Pre-handler function to parse and validate input.
65
- *
66
- * @template SV - A type that extends AnySchemaValidator.
67
- * @template Request - A type that extends ForklaunchRequest.
68
- * @template Response - A type that extends ForklaunchResponse.
69
- * @template NextFunction - A type that extends ForklaunchNextFunction.
70
- * @param {Request} req - The request object.
71
- * @param {Response} res - The response object.
72
- * @param {NextFunction} [next] - The next middleware function.
73
- */
74
- export function parseRequest(req, _res, next) {
75
- console.debug('[MIDDLEWARE] parseRequest started');
76
- const request = {
77
- params: req.params,
78
- query: req.query,
79
- headers: req.headers,
80
- body: req.body
81
- };
82
- const parsedRequest = req.schemaValidator.parse(req.requestSchema, request);
83
- if (parsedRequest.ok &&
84
- isResponseShape(parsedRequest.value)) {
85
- req.body = parsedRequest.value.body;
86
- req.params = parsedRequest.value.params;
87
- req.query = parsedRequest.value.query;
88
- req.headers = parsedRequest.value.headers;
89
- }
90
- if (!parsedRequest.ok) {
91
- switch (req.contractDetails.options?.requestValidation) {
92
- default:
93
- case 'error':
94
- next?.(new Error(`Invalid request: ${parsedRequest.error}`));
95
- break;
96
- case 'warning':
97
- console.warn(`Invalid request: ${parsedRequest.error}`);
98
- break;
99
- case 'none':
100
- break;
101
- }
102
- }
103
- next?.();
104
- }
105
- /**
106
- * Checks the authorization token for validity.
107
- *
108
- * @param {AuthMethod} [authorizationMethod] - The method of authorization.
109
- * @param {string} [authorizationString] - The authorization string.
110
- * @returns {Promise<[401 | 403, string] | string | undefined>} - The result of the authorization check.
111
- */
112
- async function checkAuthorizationToken(authorizationMethod, authorizationString) {
113
- if (!authorizationString) {
114
- return [401, 'No Authorization token provided.'];
115
- }
116
- switch (authorizationMethod) {
117
- case 'jwt': {
118
- if (!authorizationString.startsWith('Bearer ')) {
119
- return [401, 'Invalid Authorization token format.'];
120
- }
121
- try {
122
- const decodedJwt = await jose.jwtVerify(authorizationString.split(' ')[1], new TextEncoder().encode(process.env.JWT_SECRET || 'your-256-bit-secret'));
123
- return decodedJwt.payload.iss;
124
- }
125
- catch (error) {
126
- console.error(error);
127
- return [403, 'Invalid Authorization token.'];
128
- }
129
- }
130
- default:
131
- return [401, 'Invalid Authorization method.'];
132
- }
133
- }
134
- /**
135
- * Maps roles from authorization.
136
- *
137
- * @param {AuthMethod} [authorizationType] - The method of authorization.
138
- * @param {string} [authorizationToken] - The authorization token.
139
- * @returns {string[]} - The mapped roles.
140
- */
141
- // function mapRoles(
142
- // authorizationType?: AuthMethod,
143
- // authorizationToken?: string
144
- // ): string[] {
145
- // return [];
146
- // }
147
- /**
148
- * Maps permissions from authorization.
149
- *
150
- * @param {AuthMethod} [authorizationType] - The method of authorization.
151
- * @param {string} [authorizationToken] - The authorization token.
152
- * @returns {string[]} - The mapped permissions.
153
- */
154
- // function mapPermissions(
155
- // authorizationType?: AuthMethod,
156
- // authorizationToken?: string
157
- // ): string[] {
158
- // return [];
159
- // }
160
- /**
161
- * Middleware to parse request authorization.
162
- *
163
- * @template SV - A type that extends AnySchemaValidator.
164
- * @template Request - A type that extends ForklaunchRequest.
165
- * @template Response - A type that extends ForklaunchResponse.
166
- * @template NextFunction - A type that extends ForklaunchNextFunction.
167
- * @param {Request} req - The request object.
168
- * @param {Response} res - The response object.
169
- * @param {NextFunction} [next] - The next middleware function.
170
- */
171
- export async function parseRequestAuth(req, res, next) {
172
- const auth = req.contractDetails.auth;
173
- if (auth) {
174
- const errorAndMessage = await checkAuthorizationToken(auth.method, req.headers.authorization);
175
- if (Array.isArray(errorAndMessage)) {
176
- res.status(errorAndMessage[0]).send(errorAndMessage[1]);
177
- next?.(new Error(errorAndMessage[1]));
178
- }
179
- // TODO: Implement role and permission checking
180
- // const permissionSlugs = mapPermissions(
181
- // auth.method,
182
- // req.headers.authorization
183
- // );
184
- // const roles = mapRoles(auth.method, req.headers.authorization);
185
- // const permissionErrorMessage =
186
- // 'User does not have sufficient permissions to perform action.';
187
- // const roleErrorMessage =
188
- // 'User does not have correct role to perform action.';
189
- // permissionSlugs.forEach((permissionSlug) => {
190
- // if (
191
- // !req.contractDetails.auth?.allowedSlugs?.has(permissionSlug) ||
192
- // req.contractDetails.auth?.forbiddenSlugs?.has(permissionSlug)
193
- // ) {
194
- // res.status(403).send(permissionErrorMessage);
195
- // next?.(new Error(permissionErrorMessage));
196
- // }
197
- // }
198
- // });
199
- // roles.forEach((role) => {
200
- // if (
201
- // !req.contractDetails.auth?.allowedRoles?.has(role) ||
202
- // req.contractDetails.auth?.forbiddenRoles?.has(role)
203
- // ) {
204
- // res.status(403).send(roleErrorMessage);
205
- // next?.(new Error(roleErrorMessage));
206
- // }
207
- // });
208
- }
209
- // next?.();
210
- }
@@ -1,27 +0,0 @@
1
- /**
2
- * Middleware to parse and validate the response according to the provided schema.
3
- *
4
- * This function validates the response against a schema provided by the request's schema validator.
5
- * If the response does not conform to the schema, the behavior is determined by the `responseValidation`
6
- * option in `req.contractDetails.options`:
7
- * - `'error'` (default): Calls `next` with an error.
8
- * - `'warning'`: Logs a warning to the console.
9
- * - `'none'`: Silently continues without action.
10
- *
11
- * @template SV - The type of the schema validator used in the request.
12
- * @template P - The type of the parameters dictionary used in the request.
13
- * @template ResBodyMap - A record type mapping status codes to response body types.
14
- * @template ReqBody - The type of the request body.
15
- * @template ReqQuery - The type of the parsed query string.
16
- * @template ReqHeaders - The type of the request headers.
17
- * @template ResHeaders - The type of the response headers, extended from `ForklaunchResHeaders`.
18
- * @template LocalsObj - The type of the locals object in the response.
19
- *
20
- * @param {ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders>} req - The request object, containing the schema validator and other request data.
21
- * @param {ForklaunchResponse<ResBodyMap, ForklaunchResHeaders & ResHeaders, LocalsObj>} res - The response object, including headers and body data.
22
- * @param {ForklaunchNextFunction} [next] - The next middleware function to be called. If not provided, the function will return after processing.
23
- *
24
- * @returns {void} This function does not return a value.
25
- */
26
- export function parseResponse<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj>(req: ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders>, res: ForklaunchResponse<ResBodyMap, ForklaunchResHeaders & ResHeaders, LocalsObj>, next?: any): void;
27
- //# sourceMappingURL=response.middleware.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"response.middleware.d.ts","sourceRoot":"","sources":["../../../../dist/http/middleware/response.middleware.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,8BAfa,EAAE,EACF,CAAC,EACD,UAAU,EACV,OAAO,EACP,QAAQ,EACR,UAAU,EACV,UAAU,EACV,SAAS,OAEX,iBAAiB,CAAC,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,OACvD,kBAAkB,CAAC,UAAU,EAAE,oBAAoB,GAAG,UAAU,EAAE,SAAS,CAAC,eAG1E,IAAI,CA4BhB"}
@@ -1,52 +0,0 @@
1
- /**
2
- * Middleware to parse and validate the response according to the provided schema.
3
- *
4
- * This function validates the response against a schema provided by the request's schema validator.
5
- * If the response does not conform to the schema, the behavior is determined by the `responseValidation`
6
- * option in `req.contractDetails.options`:
7
- * - `'error'` (default): Calls `next` with an error.
8
- * - `'warning'`: Logs a warning to the console.
9
- * - `'none'`: Silently continues without action.
10
- *
11
- * @template SV - The type of the schema validator used in the request.
12
- * @template P - The type of the parameters dictionary used in the request.
13
- * @template ResBodyMap - A record type mapping status codes to response body types.
14
- * @template ReqBody - The type of the request body.
15
- * @template ReqQuery - The type of the parsed query string.
16
- * @template ReqHeaders - The type of the request headers.
17
- * @template ResHeaders - The type of the response headers, extended from `ForklaunchResHeaders`.
18
- * @template LocalsObj - The type of the locals object in the response.
19
- *
20
- * @param {ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders>} req - The request object, containing the schema validator and other request data.
21
- * @param {ForklaunchResponse<ResBodyMap, ForklaunchResHeaders & ResHeaders, LocalsObj>} res - The response object, including headers and body data.
22
- * @param {ForklaunchNextFunction} [next] - The next middleware function to be called. If not provided, the function will return after processing.
23
- *
24
- * @returns {void} This function does not return a value.
25
- */
26
- export function parseResponse(req, res, next) {
27
- console.debug('[MIDDLEWARE] parseResponse started');
28
- const { headers, responses } = res.responseSchemas;
29
- const parsedResponse = req.schemaValidator.parse(responses?.[res.statusCode], res.bodyData);
30
- const parsedHeaders = req.schemaValidator.parse(headers, res.getHeaders());
31
- const parseErrors = [];
32
- if (!parsedHeaders.ok) {
33
- parseErrors.push(`${parsedHeaders.error ? `Header ${parsedHeaders.error}` : ''}`);
34
- }
35
- if (!parsedResponse.ok) {
36
- parseErrors.push(`${parsedResponse.error ? `Response ${parsedResponse.error}` : ''}`);
37
- }
38
- if (parseErrors.length > 0) {
39
- switch (req.contractDetails.options?.responseValidation) {
40
- default:
41
- case 'error':
42
- next?.(new Error(`Invalid response:\n${parseErrors.join('\n\n')}`));
43
- break;
44
- case 'warning':
45
- console.warn(`Invalid response:\n${parseErrors.join('\n\n')}`);
46
- break;
47
- case 'none':
48
- break;
49
- }
50
- }
51
- next?.();
52
- }
@@ -1,2 +0,0 @@
1
- export * from "./openApiV3Generator";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../dist/http/openApiV3Generator/index.js"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- export * from './openApiV3Generator';
@@ -1,11 +0,0 @@
1
- /**
2
- * Generates a Swagger document from given routers.
3
- *
4
- * @template SV - A type that extends AnySchemaValidator.
5
- * @param {SV} schemaValidator - The schema validator.
6
- * @param {string | number} port - The port on which the server is running.
7
- * @param {ForklaunchRouter<SV>[]} routers - The routers to include in the Swagger document.
8
- * @returns {OpenAPIObject} - The generated Swagger document.
9
- */
10
- export function generateSwaggerDocument<SV>(schemaValidator: SV, port: string | number, routers: ForklaunchRouter<SV>[]): OpenAPIObject;
11
- //# sourceMappingURL=openApiV3Generator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"openApiV3Generator.d.ts","sourceRoot":"","sources":["../../../../dist/http/openApiV3Generator/openApiV3Generator.js"],"names":[],"mappings":"AA6EA;;;;;;;;GAQG;AACH,wCANa,EAAE,mBACJ,EAAE,QACF,MAAM,GAAG,MAAM,WACf,gBAAgB,CAAC,EAAE,CAAC,EAAE,GACpB,aAAa,CAkFzB"}
@@ -1,167 +0,0 @@
1
- import HTTPStatuses from '../utils/httpStatusCodes';
2
- /**
3
- * Capitalizes the first letter of a string.
4
- *
5
- * @param {string} str - The string to transform.
6
- * @returns {string} - The transformed string with the first letter capitalized.
7
- */
8
- function toUpperCase(str) {
9
- return str.charAt(0).toUpperCase() + str.slice(1);
10
- }
11
- /**
12
- * Transforms a base path by ensuring it starts with a slash and capitalizing the first letter.
13
- *
14
- * @param {string} basePath - The base path to transform.
15
- * @returns {string} - The transformed base path.
16
- */
17
- function transformBasePath(basePath) {
18
- if (basePath.startsWith('/')) {
19
- return toUpperCase(basePath.slice(1));
20
- }
21
- return `/${basePath}`;
22
- }
23
- /**
24
- * Creates a Swagger document.
25
- *
26
- * @param {string | number} port - The port on which the server is running.
27
- * @param {TagObject[]} tags - The tags for the Swagger document.
28
- * @param {PathObject} paths - The paths for the Swagger document.
29
- * @returns {OpenAPIObject} - The Swagger document.
30
- */
31
- function swaggerDocument(port, tags, paths) {
32
- return {
33
- openapi: '3.1.0',
34
- info: {
35
- title: process.env.API_TITLE || '',
36
- version: process.env.VERSION || '1.0.0'
37
- },
38
- components: {
39
- securitySchemes: {
40
- bearer: {
41
- type: 'http',
42
- scheme: 'bearer',
43
- bearerFormat: 'JWT'
44
- }
45
- }
46
- },
47
- tags,
48
- servers: [
49
- {
50
- url: `http://localhost:${port}`
51
- }
52
- ],
53
- paths
54
- };
55
- }
56
- /**
57
- * Resolves the content object for a given schema.
58
- *
59
- * @template SV - A type that extends AnySchemaValidator.
60
- * @param {SV} schemaValidator - The schema validator.
61
- * @param {IdiomaticSchema<SV>} body - The schema body.
62
- * @returns {ContentObject} - The resolved content object.
63
- */
64
- function contentResolver(schemaValidator, body) {
65
- const bodySpec = schemaValidator.openapi(body);
66
- return body === schemaValidator.string
67
- ? {
68
- 'plain/text': {
69
- schema: bodySpec
70
- }
71
- }
72
- : {
73
- 'application/json': {
74
- schema: bodySpec
75
- }
76
- };
77
- }
78
- /**
79
- * Generates a Swagger document from given routers.
80
- *
81
- * @template SV - A type that extends AnySchemaValidator.
82
- * @param {SV} schemaValidator - The schema validator.
83
- * @param {string | number} port - The port on which the server is running.
84
- * @param {ForklaunchRouter<SV>[]} routers - The routers to include in the Swagger document.
85
- * @returns {OpenAPIObject} - The generated Swagger document.
86
- */
87
- export function generateSwaggerDocument(schemaValidator, port, routers) {
88
- const tags = [];
89
- const paths = {};
90
- routers.forEach((router) => {
91
- const controllerName = transformBasePath(router.basePath);
92
- tags.push({
93
- name: controllerName,
94
- description: `${controllerName} Operations`
95
- });
96
- router.routes.forEach((route) => {
97
- const fullPath = `${router.basePath}${route.path === '/' ? '' : route.path}`.replace(/:(\w+)/g, '{$1}');
98
- if (!paths[fullPath]) {
99
- paths[fullPath] = {};
100
- }
101
- const { name, summary, query, requestHeaders } = route.contractDetails;
102
- const responses = {};
103
- for (const key in route.contractDetails.responses) {
104
- responses[key] = {
105
- description: HTTPStatuses[key],
106
- content: contentResolver(schemaValidator, route.contractDetails.responses[key])
107
- };
108
- }
109
- const pathItemObject = {
110
- tags: [controllerName],
111
- summary: `${name}: ${summary}`,
112
- parameters: [],
113
- responses
114
- };
115
- if (route.contractDetails.params) {
116
- for (const key in route.contractDetails.params) {
117
- pathItemObject.parameters?.push({
118
- name: key,
119
- in: 'path'
120
- });
121
- }
122
- }
123
- const body = route.contractDetails.body;
124
- if (body) {
125
- pathItemObject.requestBody = {
126
- required: true,
127
- content: contentResolver(schemaValidator, body)
128
- };
129
- }
130
- if (requestHeaders) {
131
- for (const key in requestHeaders) {
132
- pathItemObject.parameters?.push({
133
- name: key,
134
- in: 'header'
135
- });
136
- }
137
- }
138
- if (query) {
139
- for (const key in query) {
140
- pathItemObject.parameters?.push({
141
- name: key,
142
- in: 'query'
143
- });
144
- }
145
- }
146
- if (route.contractDetails.auth) {
147
- responses[401] = {
148
- description: HTTPStatuses[401],
149
- content: contentResolver(schemaValidator, schemaValidator.string)
150
- };
151
- responses[403] = {
152
- description: HTTPStatuses[403],
153
- content: contentResolver(schemaValidator, schemaValidator.string)
154
- };
155
- if (route.contractDetails.auth.method === 'jwt') {
156
- pathItemObject.security = [
157
- {
158
- bearer: Array.from(route.contractDetails.auth.allowedSlugs?.values() || [])
159
- }
160
- ];
161
- }
162
- }
163
- paths[fullPath][route.method] = pathItemObject;
164
- });
165
- });
166
- return swaggerDocument(port, tags, paths);
167
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=apiDefinition.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apiDefinition.types.d.ts","sourceRoot":"","sources":["../../../../dist/http/types/apiDefinition.types.js"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=contractDetails.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contractDetails.types.d.ts","sourceRoot":"","sources":["../../../../dist/http/types/contractDetails.types.js"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- export * from "./apiDefinition.types";
2
- export * from "./contractDetails.types";
3
- export * from "./router.types";
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../dist/http/types/index.js"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- export * from './apiDefinition.types';
2
- export * from './contractDetails.types';
3
- export * from './router.types';
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=router.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"router.types.d.ts","sourceRoot":"","sources":["../../../../dist/http/types/router.types.js"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- export {};
@@ -1,28 +0,0 @@
1
- /**
2
- * Enhances the Express-like `send` method with additional logic for response handling and validation.
3
- *
4
- * This function intercepts the `send` method to provide custom behavior, including response validation
5
- * through the `parseResponse` middleware. If the response status is 404, it sends a "Not Found" message.
6
- * If the response validation fails, it sends a parsing error message. Otherwise, it calls the original `send`
7
- * method with the provided data.
8
- *
9
- * @template SV - The type of the schema validator used in the request.
10
- * @template P - The type of the parameters dictionary used in the request.
11
- * @template ResBodyMap - A record type mapping status codes to response body types.
12
- * @template ReqBody - The type of the request body.
13
- * @template ReqQuery - The type of the parsed query string.
14
- * @template ReqHeaders - The type of the request headers.
15
- * @template ResHeaders - The type of the response headers, extended from `ForklaunchResHeaders`.
16
- * @template LocalsObj - The type of the locals object in the response.
17
- *
18
- * @param {unknown} instance - The context (typically `this`) in which the original `send` method is called.
19
- * @param {ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders>} req - The request object, containing the schema validator and other request data.
20
- * @param {ForklaunchResponse<ResBodyMap, ForklaunchResHeaders & ResHeaders, LocalsObj>} res - The response object, including headers and body data.
21
- * @param {Function} originalSend - The original `send` method from the response object, to be called after custom logic.
22
- * @param {string | ArrayBuffer | ArrayBufferView | NodeJS.ReadableStream | null | undefined} data - The data to be sent as the response body.
23
- * @param {boolean} shouldEnrich - A flag indicating whether the response should be sent immediately.
24
- *
25
- * @returns {unknown} The return value of the original `send` method, typically the response itself.
26
- */
27
- export function enrichExpressLikeSend<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj>(instance: unknown, req: ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders>, res: ForklaunchResponse<ResBodyMap, ForklaunchResHeaders & ResHeaders, LocalsObj>, originalSend: Function, data: string | ArrayBuffer | ArrayBufferView | NodeJS.ReadableStream | null | undefined, shouldEnrich: boolean): unknown;
28
- //# sourceMappingURL=enrichExpressLikeSend.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"enrichExpressLikeSend.d.ts","sourceRoot":"","sources":["../../../../dist/http/utils/enrichExpressLikeSend.js"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,sCAlBa,EAAE,EACF,CAAC,EACD,UAAU,EACV,OAAO,EACP,QAAQ,EACR,UAAU,EACV,UAAU,EACV,SAAS,YAEX,OAAO,OACP,iBAAiB,CAAC,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,OACvD,kBAAkB,CAAC,UAAU,EAAE,oBAAoB,GAAG,UAAU,EAAE,SAAS,CAAC,gCAE5E,MAAM,GAAG,WAAW,GAAG,eAAe,GAAG,MAAM,CAAC,cAAc,GAAG,IAAI,GAAG,SAAS,gBACjF,OAAO,GAEL,OAAO,CAwBnB"}
@@ -1,50 +0,0 @@
1
- import { parseResponse } from '../middleware';
2
- /**
3
- * Enhances the Express-like `send` method with additional logic for response handling and validation.
4
- *
5
- * This function intercepts the `send` method to provide custom behavior, including response validation
6
- * through the `parseResponse` middleware. If the response status is 404, it sends a "Not Found" message.
7
- * If the response validation fails, it sends a parsing error message. Otherwise, it calls the original `send`
8
- * method with the provided data.
9
- *
10
- * @template SV - The type of the schema validator used in the request.
11
- * @template P - The type of the parameters dictionary used in the request.
12
- * @template ResBodyMap - A record type mapping status codes to response body types.
13
- * @template ReqBody - The type of the request body.
14
- * @template ReqQuery - The type of the parsed query string.
15
- * @template ReqHeaders - The type of the request headers.
16
- * @template ResHeaders - The type of the response headers, extended from `ForklaunchResHeaders`.
17
- * @template LocalsObj - The type of the locals object in the response.
18
- *
19
- * @param {unknown} instance - The context (typically `this`) in which the original `send` method is called.
20
- * @param {ForklaunchRequest<SV, P, ReqBody, ReqQuery, ReqHeaders>} req - The request object, containing the schema validator and other request data.
21
- * @param {ForklaunchResponse<ResBodyMap, ForklaunchResHeaders & ResHeaders, LocalsObj>} res - The response object, including headers and body data.
22
- * @param {Function} originalSend - The original `send` method from the response object, to be called after custom logic.
23
- * @param {string | ArrayBuffer | ArrayBufferView | NodeJS.ReadableStream | null | undefined} data - The data to be sent as the response body.
24
- * @param {boolean} shouldEnrich - A flag indicating whether the response should be sent immediately.
25
- *
26
- * @returns {unknown} The return value of the original `send` method, typically the response itself.
27
- */
28
- export function enrichExpressLikeSend(instance, req, res, originalSend, data, shouldEnrich) {
29
- let parseErrorSent;
30
- if (shouldEnrich) {
31
- if (res.statusCode === 404) {
32
- res.status(404);
33
- originalSend.call(instance, 'Not Found');
34
- }
35
- parseResponse(req, res, (err) => {
36
- if (err) {
37
- let errorString = err.message;
38
- if (res.locals.errorMessage) {
39
- errorString += `\n------------------\n${res.locals.errorMessage}`;
40
- }
41
- res.status(500);
42
- originalSend.call(instance, errorString);
43
- parseErrorSent = true;
44
- }
45
- });
46
- }
47
- if (!parseErrorSent) {
48
- originalSend.call(instance, data);
49
- }
50
- }