@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,322 +0,0 @@
1
- import { isHttpContractDetails } from '../guards/isHttpContractDetails';
2
- import { TypedHandler } from '../handler/typedHandler';
3
- import { cors } from '../middleware/request/cors.middleware';
4
- import { createContext } from '../middleware/request/createContext.middleware';
5
- import { enrichDetails } from '../middleware/request/enrichDetails.middleware';
6
- import { parse } from '../middleware/request/parse.middleware';
7
- /**
8
- * A class that represents an Express-like router.
9
- */
10
- export class ForklaunchExpressLikeRouter {
11
- schemaValidator;
12
- internal;
13
- routes = [];
14
- basePath;
15
- constructor(basePath, schemaValidator, internal) {
16
- this.schemaValidator = schemaValidator;
17
- this.internal = internal;
18
- this.basePath = basePath;
19
- this.internal.use(createContext(this.schemaValidator));
20
- this.internal.use(cors);
21
- }
22
- /**
23
- * Resolves middlewares based on the contract details.
24
- *
25
- * @param {PathParamHttpContractDetails<SV> | HttpContractDetails<SV>} contractDetails - The contract details.
26
- * @returns {MiddlewareHandler<SV>[]} - The resolved middlewares.
27
- */
28
- #resolveMiddlewares(contractDetails, requestSchema, responseSchemas) {
29
- return [
30
- enrichDetails(contractDetails, requestSchema, responseSchemas),
31
- parse
32
- ];
33
- }
34
- /**
35
- * Parses and runs the controller function with error handling.
36
- *
37
- * @template P - The type of request parameters.
38
- * @template ResBodyMap - The type of response body.
39
- * @template ReqBody - The type of request body.
40
- * @template ReqQuery - The type of request query.
41
- * @template LocalsObj - The type of local variables.
42
- * @template StatusCode - The type of status code.
43
- * @param {MiddlewareHandler<SV, P, ResBodyMap | string, ReqBody, ReqQuery, LocalsObj, StatusCode>} requestHandler - The request handler.
44
- * @returns {ExpressMiddlewareHandler} - The Express request handler.
45
- */
46
- #parseAndRunControllerFunction(requestHandler) {
47
- return async (req, res, next) => {
48
- if (!requestHandler) {
49
- throw new Error('Controller function is not defined');
50
- }
51
- try {
52
- await requestHandler(req, res, next);
53
- }
54
- catch (error) {
55
- next?.(error);
56
- console.error(error);
57
- if (!res.headersSent) {
58
- res.status(500).send('Internal Server Error');
59
- }
60
- }
61
- };
62
- }
63
- /**
64
- * Extracts the controller function from the provided functions.
65
- *
66
- * @template P - The type of request parameters.
67
- * @template ResBodyMap - The type of response body.
68
- * @template ReqBody - The type of request body.
69
- * @template ReqQuery - The type of request query.
70
- * @template LocalsObj - The type of local variables.
71
- * @param {MiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[]} functions - The provided functions.
72
- * @returns {MiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>} - The extracted controller function.
73
- * @throws {Error} - Throws an error if the last argument is not a function.
74
- */
75
- #extractControllerFunction(functions) {
76
- const controllerFunction = functions.pop();
77
- if (typeof controllerFunction !== 'function') {
78
- throw new Error('Last argument must be a function');
79
- }
80
- return controllerFunction;
81
- }
82
- // TODO: Move to UniversalSDK
83
- // /**
84
- // * Extracts the SDK path from the given path.
85
- // *
86
- // * @param {string | RegExp | (string | RegExp)[]} path - The provided path.
87
- // * @returns {string} - The extracted SDK path.
88
- // * @throws {Error} - Throws an error if the path is not defined.
89
- // */
90
- // extractSdkPath(path: string | RegExp | (string | RegExp)[]): string {
91
- // let sdkPath = path;
92
- // if (Array.isArray(path)) {
93
- // sdkPath = path.pop() || path[0];
94
- // }
95
- // if (!sdkPath) {
96
- // throw new Error('Path is not defined');
97
- // }
98
- // if (sdkPath instanceof RegExp) {
99
- // sdkPath = generateStringFromRegex(sdkPath);
100
- // }
101
- // return sdkPath as string;
102
- // }
103
- /**
104
- * Registers middleware to the router.
105
- *
106
- * @param {...unknown[]} args - The middleware to register.
107
- * @returns {this} - The router instance.
108
- */
109
- use(...args) {
110
- this.internal.use(...args);
111
- return this;
112
- }
113
- #compile(contractDetails) {
114
- const schemaValidator = this.schemaValidator;
115
- const requestSchema = schemaValidator.compile(schemaValidator.schemify({
116
- ...(contractDetails.params ? { params: contractDetails.params } : {}),
117
- ...(contractDetails.requestHeaders
118
- ? { headers: contractDetails.requestHeaders }
119
- : {}),
120
- ...(contractDetails.query ? { query: contractDetails.query } : {}),
121
- ...(isHttpContractDetails(contractDetails) && contractDetails.body
122
- ? { body: contractDetails.body }
123
- : {})
124
- }));
125
- const responseEntries = {
126
- 400: schemaValidator.string,
127
- 401: schemaValidator.string,
128
- 403: schemaValidator.string,
129
- 404: schemaValidator.string,
130
- 500: schemaValidator.string,
131
- ...contractDetails.responses
132
- };
133
- const responseSchemas = {
134
- responses: {},
135
- ...(contractDetails.responseHeaders
136
- ? {
137
- headers: schemaValidator.compile(schemaValidator.schemify(contractDetails.responseHeaders))
138
- }
139
- : {})
140
- };
141
- Object.entries(responseEntries).forEach(([code, responseShape]) => {
142
- responseSchemas.responses[Number(code)] = schemaValidator.compile(schemaValidator.schemify(responseShape));
143
- });
144
- return {
145
- requestSchema,
146
- responseSchemas
147
- };
148
- }
149
- /**
150
- * Executes request locally, applying parameters
151
- *
152
- * @param functions {ForklaunchMiddlewareHandler<SV>}
153
- * @param controllerFunction
154
- * @returns
155
- */
156
- #localParamRequest(functions, controllerFunction) {
157
- return async (route, request) => {
158
- let statusCode;
159
- let responseMessage;
160
- const responseHeaders = {};
161
- const req = {
162
- params: request?.params ?? {},
163
- query: request?.query ?? {},
164
- headers: request?.headers ?? {},
165
- body: request?.body ?? {},
166
- path: route
167
- };
168
- const res = {
169
- status: (code) => {
170
- statusCode = code;
171
- return res;
172
- },
173
- send: (message) => {
174
- responseMessage = message;
175
- },
176
- json: (body) => {
177
- responseMessage = body;
178
- },
179
- jsonp: (body) => {
180
- responseMessage = body;
181
- },
182
- setHeader: (key, value) => {
183
- responseHeaders[key] = value;
184
- }
185
- };
186
- let cursor = functions.shift();
187
- if (cursor) {
188
- for (const fn of functions) {
189
- await cursor(req, res, (err) => {
190
- if (err) {
191
- throw err;
192
- }
193
- cursor = fn;
194
- });
195
- }
196
- await cursor(req, res, async (err) => {
197
- if (err) {
198
- throw err;
199
- }
200
- });
201
- }
202
- const cFunction = controllerFunction;
203
- await cFunction(req, res, (err) => {
204
- if (err) {
205
- throw err;
206
- }
207
- });
208
- return {
209
- code: statusCode,
210
- response: responseMessage,
211
- headers: responseHeaders
212
- };
213
- };
214
- }
215
- #registerRoute(method, path, registrationFunction, contractDetailsOrTypedHandler, ...functions) {
216
- if (contractDetailsOrTypedHandler instanceof TypedHandler) {
217
- const typedHandler = contractDetailsOrTypedHandler;
218
- return this.#registerRoute(method, path, registrationFunction, typedHandler.contractDetails, ...typedHandler.functions.concat(functions));
219
- }
220
- const contractDetails = contractDetailsOrTypedHandler;
221
- this.routes.push({
222
- basePath: this.basePath,
223
- path,
224
- method,
225
- contractDetails
226
- });
227
- const { requestSchema, responseSchemas } = this.#compile(contractDetails);
228
- const controllerFunction = this.#extractControllerFunction(functions);
229
- registrationFunction.bind(this.internal)(path, ...this.#resolveMiddlewares(contractDetails, requestSchema, responseSchemas).concat(functions), this.#parseAndRunControllerFunction(controllerFunction));
230
- return this.#localParamRequest(functions, controllerFunction);
231
- }
232
- /**
233
- * Registers a GET route with the specified contract details and handler functions.
234
- *
235
- * @template P - The type of request parameters.
236
- * @template ResBodyMap - The type of response body.
237
- * @template ReqBody - The type of request body.
238
- * @template ReqQuery - The type of request query.
239
- * @template LocalsObj - The type of local variables.
240
- * @param {string} path - The path for the route.
241
- * @param {PathParamHttpContractDetails<SV, P, ResBodyMap, ReqQuery>} contractDetails - The contract details.
242
- * @param {...SchemaMiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[]} functions - The handler functions.
243
- * @returns {ExpressRouter} - The Express router.
244
- */
245
- get(path, contractDetailsOrTypedHandler, ...functions) {
246
- return {
247
- get: this.#registerRoute('get', path, this.internal.get, contractDetailsOrTypedHandler, ...functions)
248
- };
249
- }
250
- /**
251
- * Registers a POST route with the specified contract details and handler functions.
252
- *
253
- * @template P - The type of request parameters.
254
- * @template ResBodyMap - The type of response body.
255
- * @template ReqBody - The type of request body.
256
- * @template ReqQuery - The type of request query.
257
- * @template LocalsObj - The type of local variables.
258
- * @param {string} path - The path for the route.
259
- * @param {HttpContractDetails<SV, P, ResBodyMap, ReqBody, ReqQuery>} contractDetails - The contract details.
260
- * @param {...SchemaMiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[]} functions - The handler functions.
261
- * @returns {ExpressRouter} - The Express router.
262
- */
263
- post(path, contractDetailsOrTypedHandler, ...functions) {
264
- return {
265
- post: this.#registerRoute('post', path, this.internal.post, contractDetailsOrTypedHandler, ...functions)
266
- };
267
- }
268
- /**
269
- * Registers a PUT route with the specified contract details and handler functions.
270
- *
271
- * @template P - The type of request parameters.
272
- * @template ResBodyMap - The type of response body.
273
- * @template ReqBody - The type of request body.
274
- * @template ReqQuery - The type of request query.
275
- * @template LocalsObj - The type of local variables.
276
- * @param {string} path - The path for the route.
277
- * @param {HttpContractDetails<SV, P, ResBodyMap, ReqBody, ReqQuery>} contractDetails - The contract details.
278
- * @param {...SchemaMiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[]} functions - The handler functions.
279
- * @returns {ExpressRouter} - The Express router.
280
- */
281
- put(path, contractDetailsOrTypedHandler, ...functions) {
282
- return {
283
- put: this.#registerRoute('put', path, this.internal.put, contractDetailsOrTypedHandler, ...functions)
284
- };
285
- }
286
- /**
287
- * Registers a PATCH route with the specified contract details and handler functions.
288
- *
289
- * @template P - The type of request parameters.
290
- * @template ResBodyMap - The type of response body.
291
- * @template ReqBody - The type of request body.
292
- * @template ReqQuery - The type of request query.
293
- * @template LocalsObj - The type of local variables.
294
- * @param {string} path - The path for the route.
295
- * @param {HttpContractDetails<SV, P, ResBodyMap, ReqBody, ReqQuery>} contractDetails - The contract details.
296
- * @param {...SchemaMiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[]} functions - The handler functions.
297
- * @returns {ExpressRouter} - The Express router.
298
- */
299
- patch(path, contractDetailsOrTypedHandler, ...functions) {
300
- return {
301
- patch: this.#registerRoute('patch', path, this.internal.patch, contractDetailsOrTypedHandler, ...functions)
302
- };
303
- }
304
- /**
305
- * Registers a DELETE route with the specified contract details and handler functions.
306
- *
307
- * @template P - The type of request parameters.
308
- * @template ResBodyMap - The type of response body.
309
- * @template ReqBody - The type of request body.
310
- * @template ReqQuery - The type of request query.
311
- * @template LocalsObj - The type of local variables.
312
- * @param {string} path - The path for the route.
313
- * @param {PathParamHttpContractDetails<SV, P, ResBodyMap, ReqQuery>} contractDetails - The contract details.
314
- * @param {...SchemaMiddlewareHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, LocalsObj>[]} functions - The handler functions.
315
- * @returns {ExpressRouter} - The Express router.
316
- */
317
- delete(path, contractDetailsOrTypedHandler, ...functions) {
318
- return {
319
- delete: this.#registerRoute('delete', path, this.internal.delete, contractDetailsOrTypedHandler, ...functions)
320
- };
321
- }
322
- }
@@ -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/lib/src/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/lib/src/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/lib/src/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/lib/src/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/lib/src/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 { parse } from '../middleware/response/parse.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
- parse(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
- }