jimpex 7.0.1 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (388) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/LICENSE +1 -1
  3. package/README.md +446 -434
  4. package/dist/app/index.d.ts +13 -0
  5. package/dist/app/index.js +19 -0
  6. package/dist/app/index.js.map +1 -0
  7. package/dist/app/jimpex.d.ts +13 -0
  8. package/dist/app/jimpex.js +440 -0
  9. package/dist/app/jimpex.js.map +1 -0
  10. package/dist/controllers/common/config.d.ts +78 -0
  11. package/dist/controllers/common/config.js +89 -0
  12. package/dist/controllers/common/config.js.map +1 -0
  13. package/dist/controllers/common/health.d.ts +82 -0
  14. package/dist/controllers/common/health.js +97 -0
  15. package/dist/controllers/common/health.js.map +1 -0
  16. package/dist/controllers/common/index.d.ts +21 -0
  17. package/dist/controllers/common/index.js +21 -0
  18. package/dist/controllers/common/index.js.map +1 -0
  19. package/dist/controllers/common/statics.d.ts +215 -0
  20. package/dist/controllers/common/statics.js +202 -0
  21. package/dist/controllers/common/statics.js.map +1 -0
  22. package/dist/controllers/index.d.ts +24 -0
  23. package/dist/controllers/index.js +20 -0
  24. package/dist/controllers/index.js.map +1 -0
  25. package/dist/controllers/utils/gateway.d.ts +724 -0
  26. package/dist/controllers/utils/gateway.js +425 -0
  27. package/dist/controllers/utils/gateway.js.map +1 -0
  28. package/dist/controllers/utils/index.d.ts +16 -0
  29. package/dist/controllers/utils/index.js +19 -0
  30. package/dist/controllers/utils/index.js.map +1 -0
  31. package/dist/esm/app/index.js +2 -0
  32. package/dist/esm/app/index.js.map +1 -0
  33. package/dist/esm/app/jimpex.js +415 -0
  34. package/dist/esm/app/jimpex.js.map +1 -0
  35. package/dist/esm/chunk-T2T6Q22Z.js +11 -0
  36. package/dist/esm/chunk-T2T6Q22Z.js.map +1 -0
  37. package/dist/esm/controllers/common/config.js +62 -0
  38. package/dist/esm/controllers/common/config.js.map +1 -0
  39. package/dist/esm/controllers/common/health.js +70 -0
  40. package/dist/esm/controllers/common/health.js.map +1 -0
  41. package/dist/esm/controllers/common/index.js +4 -0
  42. package/dist/esm/controllers/common/index.js.map +1 -0
  43. package/dist/esm/controllers/common/statics.js +173 -0
  44. package/dist/esm/controllers/common/statics.js.map +1 -0
  45. package/dist/esm/controllers/index.js +3 -0
  46. package/dist/esm/controllers/index.js.map +1 -0
  47. package/dist/esm/controllers/utils/gateway.js +404 -0
  48. package/dist/esm/controllers/utils/gateway.js.map +1 -0
  49. package/dist/esm/controllers/utils/index.js +2 -0
  50. package/dist/esm/controllers/utils/index.js.map +1 -0
  51. package/dist/esm/index.js +7 -0
  52. package/dist/esm/index.js.map +1 -0
  53. package/dist/esm/middlewares/common/errorHandler.js +92 -0
  54. package/dist/esm/middlewares/common/errorHandler.js.map +1 -0
  55. package/dist/esm/middlewares/common/forceHTTPS.js +41 -0
  56. package/dist/esm/middlewares/common/forceHTTPS.js.map +1 -0
  57. package/dist/esm/middlewares/common/hsts.js +53 -0
  58. package/dist/esm/middlewares/common/hsts.js.map +1 -0
  59. package/dist/esm/middlewares/common/index.js +4 -0
  60. package/dist/esm/middlewares/common/index.js.map +1 -0
  61. package/dist/esm/middlewares/html/fastHTML.js +104 -0
  62. package/dist/esm/middlewares/html/fastHTML.js.map +1 -0
  63. package/dist/esm/middlewares/html/index.js +3 -0
  64. package/dist/esm/middlewares/html/index.js.map +1 -0
  65. package/dist/esm/middlewares/html/showHTML.js +68 -0
  66. package/dist/esm/middlewares/html/showHTML.js.map +1 -0
  67. package/dist/esm/middlewares/index.js +4 -0
  68. package/dist/esm/middlewares/index.js.map +1 -0
  69. package/dist/esm/middlewares/utils/index.js +2 -0
  70. package/dist/esm/middlewares/utils/index.js.map +1 -0
  71. package/dist/esm/middlewares/utils/versionValidator.js +101 -0
  72. package/dist/esm/middlewares/utils/versionValidator.js.map +1 -0
  73. package/dist/esm/services/common/appError.js +52 -0
  74. package/dist/esm/services/common/appError.js.map +1 -0
  75. package/dist/esm/services/common/httpError.js +19 -0
  76. package/dist/esm/services/common/httpError.js.map +1 -0
  77. package/dist/esm/services/common/index.js +17 -0
  78. package/dist/esm/services/common/index.js.map +1 -0
  79. package/dist/esm/services/common/sendFile.js +27 -0
  80. package/dist/esm/services/common/sendFile.js.map +1 -0
  81. package/dist/esm/services/frontend/frontendFs.js +38 -0
  82. package/dist/esm/services/frontend/frontendFs.js.map +1 -0
  83. package/dist/esm/services/frontend/index.js +11 -0
  84. package/dist/esm/services/frontend/index.js.map +1 -0
  85. package/dist/esm/services/html/htmlGenerator.js +144 -0
  86. package/dist/esm/services/html/htmlGenerator.js.map +1 -0
  87. package/dist/esm/services/html/index.js +11 -0
  88. package/dist/esm/services/html/index.js.map +1 -0
  89. package/dist/esm/services/http/apiClient.js +71 -0
  90. package/dist/esm/services/http/apiClient.js.map +1 -0
  91. package/dist/esm/services/http/http.js +125 -0
  92. package/dist/esm/services/http/http.js.map +1 -0
  93. package/dist/esm/services/http/index.js +17 -0
  94. package/dist/esm/services/http/index.js.map +1 -0
  95. package/dist/esm/services/http/responsesBuilder.js +105 -0
  96. package/dist/esm/services/http/responsesBuilder.js.map +1 -0
  97. package/dist/esm/services/index.js +6 -0
  98. package/dist/esm/services/index.js.map +1 -0
  99. package/dist/esm/services/utils/ensureBearerToken.js +78 -0
  100. package/dist/esm/services/utils/ensureBearerToken.js.map +1 -0
  101. package/dist/esm/services/utils/index.js +11 -0
  102. package/dist/esm/services/utils/index.js.map +1 -0
  103. package/dist/esm/types/events.js +1 -0
  104. package/dist/esm/types/events.js.map +1 -0
  105. package/dist/esm/types/express.js +1 -0
  106. package/dist/esm/types/express.js.map +1 -0
  107. package/dist/esm/types/http.js +1 -0
  108. package/dist/esm/types/http.js.map +1 -0
  109. package/dist/esm/types/index.js +7 -0
  110. package/dist/esm/types/index.js.map +1 -0
  111. package/dist/esm/types/options.js +1 -0
  112. package/dist/esm/types/options.js.map +1 -0
  113. package/dist/esm/types/utils.js +1 -0
  114. package/dist/esm/types/utils.js.map +1 -0
  115. package/dist/esm/types/wootils.js +1 -0
  116. package/dist/esm/types/wootils.js.map +1 -0
  117. package/dist/esm/utils/fns/index.js +5 -0
  118. package/dist/esm/utils/fns/index.js.map +1 -0
  119. package/dist/esm/utils/fns/others.js +6 -0
  120. package/dist/esm/utils/fns/others.js.map +1 -0
  121. package/dist/esm/utils/fns/routes.js +25 -0
  122. package/dist/esm/utils/fns/routes.js.map +1 -0
  123. package/dist/esm/utils/fns/statuses.js +6 -0
  124. package/dist/esm/utils/fns/statuses.js.map +1 -0
  125. package/dist/esm/utils/fns/text.js +6 -0
  126. package/dist/esm/utils/fns/text.js.map +1 -0
  127. package/dist/esm/utils/index.js +3 -0
  128. package/dist/esm/utils/index.js.map +1 -0
  129. package/dist/esm/utils/wrappers.js +41 -0
  130. package/dist/esm/utils/wrappers.js.map +1 -0
  131. package/dist/index.d.ts +46 -0
  132. package/dist/index.js +24 -0
  133. package/dist/index.js.map +1 -0
  134. package/dist/jimpex-7eaee271.d.ts +1278 -0
  135. package/dist/middlewares/common/errorHandler.d.ts +131 -0
  136. package/dist/middlewares/common/errorHandler.js +119 -0
  137. package/dist/middlewares/common/errorHandler.js.map +1 -0
  138. package/dist/middlewares/common/forceHTTPS.d.ts +68 -0
  139. package/dist/middlewares/common/forceHTTPS.js +68 -0
  140. package/dist/middlewares/common/forceHTTPS.js.map +1 -0
  141. package/dist/middlewares/common/hsts.d.ts +109 -0
  142. package/dist/middlewares/common/hsts.js +80 -0
  143. package/dist/middlewares/common/hsts.js.map +1 -0
  144. package/dist/middlewares/common/index.d.ts +21 -0
  145. package/dist/middlewares/common/index.js +21 -0
  146. package/dist/middlewares/common/index.js.map +1 -0
  147. package/dist/middlewares/html/fastHTML.d.ts +180 -0
  148. package/dist/middlewares/html/fastHTML.js +131 -0
  149. package/dist/middlewares/html/fastHTML.js.map +1 -0
  150. package/dist/middlewares/html/index.d.ts +21 -0
  151. package/dist/middlewares/html/index.js +20 -0
  152. package/dist/middlewares/html/index.js.map +1 -0
  153. package/dist/middlewares/html/showHTML.d.ts +127 -0
  154. package/dist/middlewares/html/showHTML.js +95 -0
  155. package/dist/middlewares/html/showHTML.js.map +1 -0
  156. package/dist/middlewares/index.d.ts +30 -0
  157. package/dist/middlewares/index.js +21 -0
  158. package/dist/middlewares/index.js.map +1 -0
  159. package/dist/middlewares/utils/index.d.ts +19 -0
  160. package/dist/middlewares/utils/index.js +19 -0
  161. package/dist/middlewares/utils/index.js.map +1 -0
  162. package/dist/middlewares/utils/versionValidator.d.ts +214 -0
  163. package/dist/middlewares/utils/versionValidator.js +128 -0
  164. package/dist/middlewares/utils/versionValidator.js.map +1 -0
  165. package/dist/services/common/appError.d.ts +138 -0
  166. package/dist/services/common/appError.js +80 -0
  167. package/dist/services/common/appError.js.map +1 -0
  168. package/dist/services/common/httpError.d.ts +79 -0
  169. package/dist/services/common/httpError.js +44 -0
  170. package/dist/services/common/httpError.js.map +1 -0
  171. package/dist/services/common/index.d.ts +47 -0
  172. package/dist/services/common/index.js +41 -0
  173. package/dist/services/common/index.js.map +1 -0
  174. package/dist/services/common/sendFile.d.ts +102 -0
  175. package/dist/services/common/sendFile.js +51 -0
  176. package/dist/services/common/sendFile.js.map +1 -0
  177. package/dist/services/frontend/frontendFs.d.ts +96 -0
  178. package/dist/services/frontend/frontendFs.js +71 -0
  179. package/dist/services/frontend/frontendFs.js.map +1 -0
  180. package/dist/services/frontend/index.d.ts +40 -0
  181. package/dist/services/frontend/index.js +35 -0
  182. package/dist/services/frontend/index.js.map +1 -0
  183. package/dist/services/html/htmlGenerator.d.ts +237 -0
  184. package/dist/services/html/htmlGenerator.js +171 -0
  185. package/dist/services/html/htmlGenerator.js.map +1 -0
  186. package/dist/services/html/index.d.ts +43 -0
  187. package/dist/services/html/index.js +35 -0
  188. package/dist/services/html/index.js.map +1 -0
  189. package/dist/services/http/apiClient.d.ts +169 -0
  190. package/dist/services/http/apiClient.js +96 -0
  191. package/dist/services/http/apiClient.js.map +1 -0
  192. package/dist/services/http/http.d.ts +175 -0
  193. package/dist/services/http/http.js +158 -0
  194. package/dist/services/http/http.js.map +1 -0
  195. package/dist/services/http/index.d.ts +50 -0
  196. package/dist/services/http/index.js +41 -0
  197. package/dist/services/http/index.js.map +1 -0
  198. package/dist/services/http/responsesBuilder.d.ts +178 -0
  199. package/dist/services/http/responsesBuilder.js +132 -0
  200. package/dist/services/http/responsesBuilder.js.map +1 -0
  201. package/dist/services/index.d.ts +33 -0
  202. package/dist/services/index.js +23 -0
  203. package/dist/services/index.js.map +1 -0
  204. package/dist/services/utils/ensureBearerToken.d.ts +157 -0
  205. package/dist/services/utils/ensureBearerToken.js +105 -0
  206. package/dist/services/utils/ensureBearerToken.js.map +1 -0
  207. package/dist/services/utils/index.d.ts +43 -0
  208. package/dist/services/utils/index.js +35 -0
  209. package/dist/services/utils/index.js.map +1 -0
  210. package/dist/types/events.d.ts +13 -0
  211. package/dist/types/events.js +17 -0
  212. package/dist/types/events.js.map +1 -0
  213. package/dist/types/express.d.ts +10 -0
  214. package/dist/types/express.js +17 -0
  215. package/dist/types/express.js.map +1 -0
  216. package/dist/types/http.d.ts +79 -0
  217. package/dist/types/http.js +17 -0
  218. package/dist/types/http.js.map +1 -0
  219. package/dist/types/index.d.ts +14 -0
  220. package/dist/types/index.js +24 -0
  221. package/dist/types/index.js.map +1 -0
  222. package/dist/types/options.d.ts +13 -0
  223. package/dist/types/options.js +17 -0
  224. package/dist/types/options.js.map +1 -0
  225. package/dist/types/utils.d.ts +48 -0
  226. package/dist/types/utils.js +17 -0
  227. package/dist/types/utils.js.map +1 -0
  228. package/dist/types/wootils.d.ts +4 -0
  229. package/dist/types/wootils.js +17 -0
  230. package/dist/types/wootils.js.map +1 -0
  231. package/dist/utils/fns/index.d.ts +5 -0
  232. package/dist/utils/fns/index.js +22 -0
  233. package/dist/utils/fns/index.js.map +1 -0
  234. package/dist/utils/fns/others.d.ts +17 -0
  235. package/dist/utils/fns/others.js +29 -0
  236. package/dist/utils/fns/others.js.map +1 -0
  237. package/dist/utils/fns/routes.d.ts +39 -0
  238. package/dist/utils/fns/routes.js +51 -0
  239. package/dist/utils/fns/routes.js.map +1 -0
  240. package/dist/utils/fns/statuses.d.ts +45 -0
  241. package/dist/utils/fns/statuses.js +35 -0
  242. package/dist/utils/fns/statuses.js.map +1 -0
  243. package/dist/utils/fns/text.d.ts +9 -0
  244. package/dist/utils/fns/text.js +29 -0
  245. package/dist/utils/fns/text.js.map +1 -0
  246. package/dist/utils/index.d.ts +18 -0
  247. package/dist/utils/index.js +20 -0
  248. package/dist/utils/index.js.map +1 -0
  249. package/dist/utils/wrappers.d.ts +13 -0
  250. package/dist/utils/wrappers.js +68 -0
  251. package/dist/utils/wrappers.js.map +1 -0
  252. package/examples/basic/404.html +12 -0
  253. package/examples/basic/README.md +30 -0
  254. package/examples/basic/app.ts +18 -0
  255. package/examples/basic/controller.ts +45 -0
  256. package/examples/basic/index.ts +19 -0
  257. package/examples/basic/middleware.ts +13 -0
  258. package/examples/basic/service.ts +11 -0
  259. package/package.json +59 -38
  260. package/src/app/index.ts +1 -0
  261. package/src/app/jimpex.ts +743 -0
  262. package/src/controllers/common/config.ts +115 -0
  263. package/src/controllers/common/health.ts +128 -0
  264. package/src/controllers/common/index.ts +3 -0
  265. package/src/controllers/common/statics.ts +380 -0
  266. package/src/controllers/index.ts +2 -0
  267. package/src/controllers/utils/gateway.ts +1186 -0
  268. package/src/controllers/utils/index.ts +1 -0
  269. package/src/index.ts +6 -0
  270. package/src/middlewares/common/errorHandler.ts +203 -0
  271. package/src/middlewares/common/forceHTTPS.ts +83 -0
  272. package/src/middlewares/common/hsts.ts +135 -0
  273. package/src/middlewares/common/index.ts +3 -0
  274. package/src/middlewares/html/fastHTML.ts +255 -0
  275. package/src/middlewares/html/index.ts +2 -0
  276. package/src/middlewares/html/showHTML.ts +165 -0
  277. package/src/middlewares/index.ts +3 -0
  278. package/src/middlewares/utils/index.ts +1 -0
  279. package/src/middlewares/utils/versionValidator.ts +289 -0
  280. package/src/services/common/appError.ts +158 -0
  281. package/src/services/common/httpError.ts +74 -0
  282. package/src/services/common/index.ts +29 -0
  283. package/src/services/common/sendFile.ts +106 -0
  284. package/src/services/frontend/frontendFs.ts +101 -0
  285. package/src/services/frontend/index.ts +21 -0
  286. package/src/services/html/htmlGenerator.ts +356 -0
  287. package/src/services/html/index.ts +21 -0
  288. package/src/services/http/apiClient.ts +221 -0
  289. package/src/services/http/http.ts +286 -0
  290. package/src/services/http/index.ts +29 -0
  291. package/src/services/http/responsesBuilder.ts +265 -0
  292. package/src/services/index.ts +5 -0
  293. package/src/services/utils/ensureBearerToken.ts +202 -0
  294. package/src/services/utils/index.ts +21 -0
  295. package/src/types/events.ts +303 -0
  296. package/src/types/express.ts +21 -0
  297. package/src/types/http.ts +77 -0
  298. package/src/types/index.ts +6 -0
  299. package/src/types/options.ts +248 -0
  300. package/src/types/utils.ts +52 -0
  301. package/src/types/wootils.ts +4 -0
  302. package/src/utils/fns/index.ts +4 -0
  303. package/src/utils/fns/others.ts +15 -0
  304. package/src/utils/fns/routes.ts +64 -0
  305. package/src/utils/fns/statuses.ts +44 -0
  306. package/src/utils/fns/text.ts +8 -0
  307. package/src/utils/index.ts +2 -0
  308. package/src/utils/wrappers.ts +537 -0
  309. package/tsconfig.json +5 -8
  310. package/tsup.config.ts +10 -0
  311. package/src/app/index.js +0 -692
  312. package/src/constants/eventNames.js +0 -48
  313. package/src/constants/index.js +0 -7
  314. package/src/controllers/common/configuration.js +0 -116
  315. package/src/controllers/common/health.js +0 -79
  316. package/src/controllers/common/index.js +0 -7
  317. package/src/controllers/common/statics.js +0 -336
  318. package/src/controllers/index.js +0 -9
  319. package/src/controllers/utils/gateway.js +0 -1039
  320. package/src/controllers/utils/index.js +0 -3
  321. package/src/index.js +0 -30
  322. package/src/middlewares/common/errorHandler.js +0 -185
  323. package/src/middlewares/common/forceHTTPS.js +0 -80
  324. package/src/middlewares/common/hsts.js +0 -122
  325. package/src/middlewares/common/index.js +0 -7
  326. package/src/middlewares/html/fastHTML.js +0 -298
  327. package/src/middlewares/html/index.js +0 -5
  328. package/src/middlewares/html/showHTML.js +0 -167
  329. package/src/middlewares/index.js +0 -11
  330. package/src/middlewares/utils/index.js +0 -3
  331. package/src/middlewares/utils/versionValidator.js +0 -261
  332. package/src/services/common/appError.js +0 -136
  333. package/src/services/common/httpError.js +0 -60
  334. package/src/services/common/index.js +0 -25
  335. package/src/services/common/sendFile.js +0 -68
  336. package/src/services/frontend/frontendFs.js +0 -85
  337. package/src/services/frontend/index.js +0 -17
  338. package/src/services/html/htmlGenerator.js +0 -391
  339. package/src/services/html/index.js +0 -17
  340. package/src/services/http/apiClient.js +0 -148
  341. package/src/services/http/http.js +0 -256
  342. package/src/services/http/index.js +0 -25
  343. package/src/services/http/responsesBuilder.js +0 -193
  344. package/src/services/index.js +0 -15
  345. package/src/services/utils/ensureBearerToken.js +0 -147
  346. package/src/services/utils/index.js +0 -19
  347. package/src/types.js +0 -377
  348. package/src/utils/functions.js +0 -78
  349. package/src/utils/wrappers.js +0 -131
  350. package/types/app/index.d.ts +0 -417
  351. package/types/constants/eventNames.d.ts +0 -93
  352. package/types/constants/index.d.ts +0 -2
  353. package/types/controllers/common/configuration.d.ts +0 -71
  354. package/types/controllers/common/health.d.ts +0 -55
  355. package/types/controllers/common/index.d.ts +0 -4
  356. package/types/controllers/common/statics.d.ts +0 -271
  357. package/types/controllers/index.d.ts +0 -3
  358. package/types/controllers/utils/gateway.d.ts +0 -947
  359. package/types/controllers/utils/index.d.ts +0 -2
  360. package/types/index.d.ts +0 -15
  361. package/types/middlewares/common/errorHandler.d.ts +0 -143
  362. package/types/middlewares/common/forceHTTPS.d.ts +0 -64
  363. package/types/middlewares/common/hsts.d.ts +0 -111
  364. package/types/middlewares/common/index.d.ts +0 -4
  365. package/types/middlewares/html/fastHTML.d.ts +0 -238
  366. package/types/middlewares/html/index.d.ts +0 -3
  367. package/types/middlewares/html/showHTML.d.ts +0 -128
  368. package/types/middlewares/index.d.ts +0 -4
  369. package/types/middlewares/utils/index.d.ts +0 -2
  370. package/types/middlewares/utils/versionValidator.d.ts +0 -247
  371. package/types/services/common/appError.d.ts +0 -89
  372. package/types/services/common/httpError.d.ts +0 -37
  373. package/types/services/common/index.d.ts +0 -18
  374. package/types/services/common/sendFile.d.ts +0 -56
  375. package/types/services/frontend/frontendFs.d.ts +0 -72
  376. package/types/services/frontend/index.d.ts +0 -3
  377. package/types/services/html/htmlGenerator.d.ts +0 -298
  378. package/types/services/html/index.d.ts +0 -3
  379. package/types/services/http/apiClient.d.ts +0 -141
  380. package/types/services/http/http.d.ts +0 -159
  381. package/types/services/http/index.d.ts +0 -18
  382. package/types/services/http/responsesBuilder.d.ts +0 -140
  383. package/types/services/index.d.ts +0 -6
  384. package/types/services/utils/ensureBearerToken.d.ts +0 -137
  385. package/types/services/utils/index.d.ts +0 -16
  386. package/types/types.d.ts +0 -280
  387. package/types/utils/functions.d.ts +0 -55
  388. package/types/utils/wrappers.d.ts +0 -127
@@ -1,128 +0,0 @@
1
- export type ExpressMiddleware = import('../../types').ExpressMiddleware;
2
- export type ExpressResponse = import('../../types').ExpressResponse;
3
- export type ExpressNext = import('../../types').ExpressNext;
4
- export type SendFile = import('../../services/common/sendFile').SendFile;
5
- export type HTMLGenerator = import('../../services/html/htmlGenerator').HTMLGenerator;
6
- /**
7
- * <O>
8
- */
9
- export type MiddlewareCreator<O> = import('../../types').MiddlewareCreator<O>;
10
- /**
11
- * A set options to customize the middleware behavior.
12
- */
13
- export type ShowHTMLMiddlewareOptions = {
14
- /**
15
- * The name of the file the middleware will serve.
16
- * Default `'index.html'`.
17
- */
18
- file: string;
19
- /**
20
- * The name of a {@link HTMLGenerator } service for the
21
- * middleware to use. If the service is available, the
22
- * value of `file` will be overwritten for the file
23
- * generated by the service. Default `'htmlGenerator'`.
24
- */
25
- htmlGenerator: string;
26
- };
27
- /**
28
- * @typedef {import('../../types').ExpressMiddleware} ExpressMiddleware
29
- * @typedef {import('../../types').ExpressResponse} ExpressResponse
30
- * @typedef {import('../../types').ExpressNext} ExpressNext
31
- * @typedef {import('../../services/common/sendFile').SendFile} SendFile
32
- * @typedef {import('../../services/html/htmlGenerator').HTMLGenerator} HTMLGenerator
33
- */
34
- /**
35
- * @typedef {import('../../types').MiddlewareCreator<O>} MiddlewareCreator<O>
36
- * @template O
37
- */
38
- /**
39
- * A set options to customize the middleware behavior.
40
- *
41
- * @typedef {Object} ShowHTMLMiddlewareOptions
42
- * @property {string} file The name of the file the middleware will serve.
43
- * Default `'index.html'`.
44
- * @property {string} htmlGenerator The name of a {@link HTMLGenerator} service for the
45
- * middleware to use. If the service is available, the
46
- * value of `file` will be overwritten for the file
47
- * generated by the service. Default `'htmlGenerator'`.
48
- * @parent module:middlewares
49
- */
50
- /**
51
- * A very simple middleware service to send an HTML on a server response. The special
52
- * _'feature'_ of this service is that it can be hooked up to an `HTMLGenerator` service
53
- * and it will automatically server the file generated by it.
54
- *
55
- * @parent module:middlewares
56
- */
57
- export class ShowHTML {
58
- /**
59
- * @param {SendFile} sendFile Necessary to server the HTML file.
60
- * @param {string} [file='index.html'] The name of the file it will serve. If
61
- * `htmlGenerator` is specified, this will
62
- * be overwritten with the name of the file
63
- * generated by that service.
64
- * @param {HTMLGenerator} [htmlGenerator=null] If used, the file to server will be the
65
- * one generated by that service.
66
- */
67
- constructor(sendFile: SendFile, file?: string, htmlGenerator?: HTMLGenerator);
68
- /**
69
- * A local reference for the `sendFile` service.
70
- *
71
- * @type {SendFile}
72
- * @access protected
73
- * @ignore
74
- */
75
- _sendFile: SendFile;
76
- /**
77
- * The name of the file to serve.
78
- *
79
- * @type {string}
80
- * @access protected
81
- * @ignore
82
- */
83
- _file: string;
84
- /**
85
- * If specified, a reference for a service that generates HTML files.
86
- *
87
- * @type {HTMLGenerator}
88
- * @access protected
89
- * @ignore
90
- */
91
- _htmlGenerator: HTMLGenerator;
92
- /**
93
- * Whether or not the file is ready to be served.
94
- *
95
- * @type {boolean}
96
- * @access protected
97
- * @ignore
98
- */
99
- _ready: boolean;
100
- /**
101
- * Returns the Express middleware that serves the HTML file.
102
- *
103
- * @returns {ExpressMiddleware}
104
- */
105
- middleware(): ExpressMiddleware;
106
- /**
107
- * The name of the file to serve.
108
- *
109
- * @type {string}
110
- */
111
- get file(): string;
112
- /**
113
- * Serves the file on the response.
114
- *
115
- * @param {ExpressResponse} res The server response.
116
- * @param {ExpressNext} next The functino to call the next middleware.
117
- * @access protected
118
- * @ignore
119
- */
120
- _sendHTML(res: ExpressResponse, next: ExpressNext): void;
121
- }
122
- /**
123
- * A middleware for showing an `index.html` file.
124
- *
125
- * @type {MiddlewareCreator<ShowHTMLMiddlewareOptions>}
126
- * @parent module:middlewares
127
- */
128
- export const showHTML: MiddlewareCreator<ShowHTMLMiddlewareOptions>;
@@ -1,4 +0,0 @@
1
- import common = require("./common");
2
- import html = require("./html");
3
- import utils = require("./utils");
4
- export { common, html, utils };
@@ -1,2 +0,0 @@
1
- export { versionValidator };
2
- import { versionValidator } from "./versionValidator";
@@ -1,247 +0,0 @@
1
- export type ExpressMiddleware = import('../../types').ExpressMiddleware;
2
- export type ExpressRequest = import('../../types').ExpressRequest;
3
- export type ResponsesBuilder = import('../../services/http/responsesBuilder').ResponsesBuilder;
4
- /**
5
- * <O>
6
- */
7
- export type MiddlewareCreator<O> = import('../../types').MiddlewareCreator<O>;
8
- /**
9
- * The options for how the middleware should behave if the requested version is `latest`.
10
- */
11
- export type VersionValidatorLatestOptions = {
12
- /**
13
- * Whether or not the middleware should validate the _"latest
14
- * version"_.
15
- * Default `true`.
16
- */
17
- allow: boolean;
18
- /**
19
- * The name of the _"latest version"_. Basically,
20
- * `req.params.version`
21
- * must match with this property in order to be consider
22
- * "latest".
23
- * Default `'latest'`.
24
- */
25
- name: string;
26
- };
27
- /**
28
- * The options for how to detect if the request comes from a popup and how to compose the
29
- * post message the middleware will use to respond.
30
- */
31
- export type VersionValidatorPopupOptions = {
32
- /**
33
- * The name of the query string variable the middleware will
34
- * check in order to indentify whether the request comes from
35
- * a popup or not.
36
- * The variable must have `'true'` as its value. Default
37
- * `'popup'`.
38
- */
39
- variable: string;
40
- /**
41
- * The title of the page that will be generated to respond in
42
- * case the versions don't match. Default `'Conflict'`.
43
- */
44
- title: string;
45
- /**
46
- * The contents of the post message the generated page will
47
- * send if the versions don't match. Default
48
- * `'vesion:conflict'`.
49
- */
50
- message: string;
51
- };
52
- /**
53
- * The options used to customize a {@link VersionValidator } instance.
54
- */
55
- export type VersionValidatorOptions = {
56
- /**
57
- * The error message to show when the
58
- * version is invalid.
59
- */
60
- error: string;
61
- /**
62
- * The options for how the middleware
63
- * should behave if the requested
64
- * version is `latest`.
65
- */
66
- latest: VersionValidatorLatestOptions;
67
- /**
68
- * The options for how to detect if the
69
- * request comes from a popup and how
70
- * to compose the post message the
71
- * middleware will use to respond.
72
- */
73
- popup: VersionValidatorPopupOptions;
74
- /**
75
- * The version used to validate the
76
- * requests.
77
- * On the {@link VersionValidator }constructor, if specified via
78
- * parameter,
79
- * the class will take care of
80
- * automatically add it to the options.
81
- */
82
- version: string | number;
83
- };
84
- /**
85
- * @typedef {import('../../types').ExpressMiddleware} ExpressMiddleware
86
- * @typedef {import('../../types').ExpressRequest} ExpressRequest
87
- * @typedef {import('../../services/http/responsesBuilder').ResponsesBuilder} ResponsesBuilder
88
- * @prettierignore
89
- */
90
- /**
91
- * @typedef {import('../../types').MiddlewareCreator<O>} MiddlewareCreator<O>
92
- * @template O
93
- */
94
- /**
95
- * The options for how the middleware should behave if the requested version is `latest`.
96
- *
97
- * @typedef {Object} VersionValidatorLatestOptions
98
- * @property {boolean} allow Whether or not the middleware should validate the _"latest
99
- * version"_.
100
- * Default `true`.
101
- * @property {string} name The name of the _"latest version"_. Basically,
102
- * `req.params.version`
103
- * must match with this property in order to be consider
104
- * "latest".
105
- * Default `'latest'`.
106
- * @parent module:middlewares
107
- */
108
- /**
109
- * The options for how to detect if the request comes from a popup and how to compose the
110
- * post message the middleware will use to respond.
111
- *
112
- * @typedef {Object} VersionValidatorPopupOptions
113
- * @property {string} variable The name of the query string variable the middleware will
114
- * check in order to indentify whether the request comes from
115
- * a popup or not.
116
- * The variable must have `'true'` as its value. Default
117
- * `'popup'`.
118
- * @property {string} title The title of the page that will be generated to respond in
119
- * case the versions don't match. Default `'Conflict'`.
120
- * @property {string} message The contents of the post message the generated page will
121
- * send if the versions don't match. Default
122
- * `'vesion:conflict'`.
123
- * @parent module:middlewares
124
- */
125
- /**
126
- * The options used to customize a {@link VersionValidator} instance.
127
- *
128
- * @typedef {Object} VersionValidatorOptions
129
- * @property {string} error The error message to show when the
130
- * version is invalid.
131
- * @property {VersionValidatorLatestOptions} latest The options for how the middleware
132
- * should behave if the requested
133
- * version is `latest`.
134
- * @property {VersionValidatorPopupOptions} popup The options for how to detect if the
135
- * request comes from a popup and how
136
- * to compose the post message the
137
- * middleware will use to respond.
138
- * @property {string | number} version The version used to validate the
139
- * requests.
140
- * On the {@link VersionValidator}
141
- * constructor, if specified via
142
- * parameter,
143
- * the class will take care of
144
- * automatically add it to the options.
145
- * @parent module:middlewares
146
- */
147
- /**
148
- * This is the handler for the middleware/controller that validates the app version.
149
- * This is useful in cases where you want to restrict the access to the app to specific
150
- * versions,
151
- * for example: you have a frontend app which needs to be aligned with the "current"
152
- * version of the app, since the frontend won't realize a new version was released, the
153
- * validator can be used to let the frontend know.
154
- * Also, it can be configured to handle requests from popups, in which case, instead of
155
- * generating an error message, it will send a post message.
156
- *
157
- * @parent module:middlewares
158
- */
159
- export class VersionValidator {
160
- /**
161
- * @param {?(string | ?number)} version
162
- * The current version of the app. The reason this is nullable is because this comes
163
- * directly from the app configuration, but you may want to re use this to validate
164
- * "another version", so you can use the custom shorthand and send the version using the
165
- * `options` parameter.
166
- * @param {ResponsesBuilder} responsesBuilder
167
- * To generate post message responses for popups.
168
- * @param {ClassAppError} AppError
169
- * To generate the error in case the version is invalid.
170
- * @param {Partial<VersionValidatorOptions>} [options={}]
171
- * Custom options to modify the middleware behavior.
172
- * @throws {Error}
173
- * If the version is `null` and the `options` don't include one either.
174
- */
175
- constructor(version: (string | (number | null)) | null, responsesBuilder: ResponsesBuilder, AppError: any, options?: Partial<VersionValidatorOptions>);
176
- /**
177
- * A local reference for the `responsesBuilder` service.
178
- *
179
- * @type {ResponsesBuilder}
180
- * @access protected
181
- * @ignore
182
- */
183
- _responsesBuilder: ResponsesBuilder;
184
- /**
185
- * A local reference for the class the app uses to generate errors.
186
- *
187
- * @type {ClassAppError}
188
- * @access protected
189
- * @ignore
190
- */
191
- _AppError: any;
192
- /**
193
- * These are the "settings" the middleware will use in order to validate the requests.
194
- *
195
- * @type {VersionValidatorOptions}
196
- * @access protected
197
- * @ignore
198
- */
199
- _options: VersionValidatorOptions;
200
- /**
201
- * Returns the Express middleware that will validate the `version` parameter.
202
- *
203
- * @returns {ExpressMiddleware}
204
- */
205
- middleware(): ExpressMiddleware;
206
- /**
207
- * The options used to customize the middleware behavior.
208
- *
209
- * @returns {VersionValidatorOptions}
210
- */
211
- get options(): VersionValidatorOptions;
212
- /**
213
- * Helper method that checks if the incoming request is from a popup.
214
- *
215
- * @param {ExpressRequest} req The request information.
216
- * @returns {boolean}
217
- * @access protected
218
- * @ignore
219
- */
220
- _isPopup(req: ExpressRequest): boolean;
221
- /**
222
- * Helper method that checks if the "latest version" is enabled and if the given version
223
- * is "the latest" (comparing it with the option name).
224
- *
225
- * @param {string | number} version The version to validate.
226
- * @returns {boolean}
227
- * @access protected
228
- * @ignore
229
- */
230
- _validateLatest(version: string | number): boolean;
231
- }
232
- /**
233
- * A middleware that will validate a `version` request parameter against the app version
234
- * and generate an error if they don't match.
235
- * This is a "middleware/controller" is because the wrappers for both are the same, the
236
- * difference is that, for controllers, Jimpex sends a second parameter with the route
237
- * where they are mounted.
238
- * By validating the route parameter, the function can know whether the implementation is
239
- * going to use the middleware by itself or as a route middleware.
240
- * If used as middleware, it will just return the result of
241
- * {@link VersionValidator#middleware};
242
- * but if used as controller, it will mount it on `[route]/:version/*`.
243
- *
244
- * @type {MiddlewareCreator<VersionValidatorOptions>}
245
- * @parent module:middlewares
246
- */
247
- export const versionValidator: MiddlewareCreator<VersionValidatorOptions>;
@@ -1,89 +0,0 @@
1
- export type Provider = import('../../types').Provider;
2
- /**
3
- * @typedef {import('../../types').Provider} Provider
4
- */
5
- /**
6
- * A simple subclass of `Error` but with support for context information.
7
- *
8
- * @augments Error
9
- * @parent module:services
10
- */
11
- export class AppError extends Error {
12
- /**
13
- * @param {string} message The error message.
14
- * @param {Object} [context={}] Context information related to the error.
15
- */
16
- constructor(message: string, context?: any);
17
- /**
18
- * Context information related to the error.
19
- *
20
- * @type {Object}
21
- * @access protected
22
- * @todo Remove Object.freeze.
23
- */
24
- _context: any;
25
- /**
26
- * The date of when the error was generated.
27
- *
28
- * @type {Date}
29
- * @access protected
30
- */
31
- _date: Date;
32
- /**
33
- * Context information related to the error.
34
- *
35
- * @type {Object}
36
- */
37
- get context(): any;
38
- /**
39
- * The date of when the error was generated.
40
- *
41
- * @type {Date}
42
- */
43
- get date(): Date;
44
- /**
45
- * Information about the error that can be shown on an app response. This is set using
46
- * the `response` key on the `context`. The idea is that the error handler will read it
47
- * and use it on the response.
48
- *
49
- * @returns {Object}
50
- */
51
- get response(): any;
52
- /**
53
- * An HTTP status code related to the error. This is set using the `status` key on the
54
- * `context`. If the error handler finds it, it will use it as the response status,
55
- * and use it if necessary.
56
- *
57
- * @type {?number}
58
- */
59
- get status(): number;
60
- /**
61
- * Utility method that formats the context before saving it in the instance:
62
- * - If the context includes a `status` as a `string`, it will try to replace it with
63
- * its status code from the `statuses` package.
64
- *
65
- * @param {Object} original The original context to format.
66
- * @returns {Object}
67
- * @access protected
68
- * @ignore
69
- */
70
- _parseContext(original: any): any;
71
- }
72
- /**
73
- * A service provider that will register both the {@link AppError} and a generator
74
- * function on the container. `AppError` will be the key for class, and `appError` will be
75
- * for the generator function.
76
- *
77
- * @type {Provider}
78
- * @example
79
- *
80
- * // Register it on the container
81
- * container.register(appError);
82
- * // Getting access to the class.
83
- * const AppError = container.get('AppError');
84
- * // Getting access to the function.
85
- * const appError = container.get('appError');
86
- *
87
- * @parent module:services
88
- */
89
- export const appError: Provider;
@@ -1,37 +0,0 @@
1
- export type Provider = import('../../types').Provider;
2
- /**
3
- * @typedef {import('../../types').Provider} Provider
4
- */
5
- /**
6
- * A type of error to be used on HTTP requests.
7
- *
8
- * @augments AppError
9
- * @parent module:services
10
- */
11
- export class HTTPError extends AppError {
12
- /**
13
- * @param {string} message The error message.
14
- * @param {number} [status=200] The HTTP status code of the request response.
15
- * @param {Object} [context={}] Context information related to the error.
16
- */
17
- constructor(message: string, status?: number, context?: any);
18
- }
19
- /**
20
- * A service provider that will register both the {@link HTTPError} and a generator
21
- * function on the container. `HTTPError` will be the key for class, and `httpError` will
22
- * be for the generator function.
23
- *
24
- * @type {Provider}
25
- * @example
26
- *
27
- * // Register it on the container
28
- * container.register(httpError);
29
- * // Getting access to the class.
30
- * const HTTPError = container.get('HTTPError');
31
- * // Getting access to the function.
32
- * const httpError = container.get('httpError');
33
- *
34
- * @parent module:services
35
- */
36
- export const httpError: Provider;
37
- import { AppError } from "./appError";
@@ -1,18 +0,0 @@
1
- export = commonServices;
2
- /**
3
- * @typedef {import('../../types').Provider} Provider
4
- */
5
- /**
6
- * The providers collection for the common services.
7
- *
8
- * @type {Provider}
9
- * @property {Provider} appError The provider for {@link AppError}.
10
- * @property {Provider} httpError The provider for {@link HTTPError}.
11
- * @property {Provider} sendFile The provider for {@link SendFile}.
12
- * @parent module:services
13
- */
14
- declare const commonServices: Provider;
15
- declare namespace commonServices {
16
- export { Provider };
17
- }
18
- type Provider = import('../../types').Provider;
@@ -1,56 +0,0 @@
1
- export type PathUtils = import('../../types').PathUtils;
2
- export type Provider = import('../../types').Provider;
3
- export type ExpressResponse = import('../../types').ExpressResponse;
4
- export type ExpressNext = import('../../types').ExpressNext;
5
- export type SendFile = (res: ExpressResponse, filepath: string, next: ExpressNext, from?: string) => any;
6
- /**
7
- * @typedef {import('../../types').PathUtils} PathUtils
8
- * @typedef {import('../../types').Provider} Provider
9
- * @typedef {import('../../types').ExpressResponse} ExpressResponse
10
- * @typedef {import('../../types').ExpressNext} ExpressNext
11
- */
12
- /**
13
- * @callback SendFile
14
- * @param {ExpressResponse} res Necessary to write the file.
15
- * @param {string} filepath The path to the file relative to where the app
16
- * executable is located.
17
- * @param {ExpressNext} next To call the send out the error if anything
18
- * happens.
19
- * @param {string} [from='app'] The location it uses to build the relative path.
20
- * It can be `app` for the directory where the app
21
- * executable is located, or `home` for the project
22
- * root directory.
23
- * @parent module:services
24
- */
25
- /**
26
- * Generates a function to send files with path relatives to the app executable file is
27
- * located.
28
- *
29
- * @example
30
- *
31
- * // Let's say this is inside an Express middleware.
32
- * // Get the function
33
- * const send = sendFile(pathUtils);
34
- * send(res, 'some-file.html', next);
35
- * // If your app is on `/app/index.js`, this will send `/app/some-file.html`.
36
- *
37
- * @param {PathUtils} pathUtils To generate the relative paths.
38
- * @returns {SendFile}
39
- * @parent module:services
40
- */
41
- export function sendFile(pathUtils: PathUtils): SendFile;
42
- /**
43
- * The service provider that once registered on the app container will set the result of
44
- * `sendFile(pathUtils)` as the `sendFile` service.
45
- *
46
- * @type {Provider}
47
- * @example
48
- *
49
- * // Register it on the container
50
- * container.register(sendFileProvider);
51
- * // Getting access to the service instance
52
- * const sendFile = container.get('sendFile');
53
- *
54
- * @parent module:services
55
- */
56
- export const sendFileProvider: Provider;
@@ -1,72 +0,0 @@
1
- export type PathUtils = import('../../types').PathUtils;
2
- export type Provider = import('../../types').Provider;
3
- /**
4
- * @typedef {import('../../types').PathUtils} PathUtils
5
- * @typedef {import('../../types').Provider} Provider
6
- */
7
- /**
8
- * This service allows the app to easily read static files. The idea behind centralizing
9
- * this functionalities into a service is that is pretty common to have bundling tools to
10
- * generate the frontend, and on that process files can have different paths or not even
11
- * be generated all, that's why this service exists. The service can be
12
- * extended/overwritten to accommodate any requirements and avoid having to update or add
13
- * `if`s to every `fs` call the app does.
14
- * Another _'feature'_ of this service is that all the paths are relative to the directory
15
- * where the app executable is located, so you don't have to remember the relative path
16
- * from the place you are accessing a file to the place where it's located.
17
- *
18
- * @parent module:services
19
- */
20
- export class FrontendFs {
21
- /**
22
- * @param {PathUtils} pathUtils To generate the relative paths.
23
- */
24
- constructor(pathUtils: PathUtils);
25
- /**
26
- * A local reference for the `pathUtils` service.
27
- *
28
- * @type {PathUtils}
29
- * @access protected
30
- * @ignore
31
- */
32
- _pathUtils: PathUtils;
33
- /**
34
- * Delete a file from the file system.
35
- *
36
- * @param {string} filepath The path to the file.
37
- * @returns {Promise}
38
- */
39
- delete(filepath: string): Promise<any>;
40
- /**
41
- * Read a file from the file system.
42
- *
43
- * @param {string} filepath The path to the file.
44
- * @param {string} [encoding='utf-8'] The text encoding in which the file should be
45
- * read.
46
- * @returns {Promise<string>}
47
- */
48
- read(filepath: string, encoding?: string): Promise<string>;
49
- /**
50
- * Write a file on the file system.
51
- *
52
- * @param {string} filepath The path to the file.
53
- * @param {string} data The contents of the file.
54
- * @returns {Promise}
55
- */
56
- write(filepath: string, data: string): Promise<any>;
57
- }
58
- /**
59
- * The service provider that once registered on the app container will set an instance of
60
- * `FrontendFs` as the `frontendFs` service.
61
- *
62
- * @type {Provider}
63
- * @example
64
- *
65
- * // Register it on the container
66
- * container.register(frontendFs);
67
- * // Getting access to the service instance
68
- * const frontendFs = container.get('frontendFs');
69
- *
70
- * @parent module:services
71
- */
72
- export const frontendFs: Provider;
@@ -1,3 +0,0 @@
1
- declare const _exports: Provider;
2
- export = _exports;
3
- export type Provider = import('../../types').Provider;