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,417 +0,0 @@
1
- /// <reference types="node" />
2
- import Jimple from 'jimple';
3
- export type Express = express.Express;
4
- export type SpdyServer = https.Server;
5
- export type Provider = {
6
- register: import('wootils/esm/shared/jimpleFns').ProviderRegisterFn;
7
- };
8
- export type Controller = {
9
- /**
10
- * The function Jimpex calls when mounting the
11
- * controller.
12
- */
13
- connect: import('../types').ControllerConnectFn;
14
- /**
15
- * A flag set to `true` to identify the
16
- * resource as a routes controller.
17
- */
18
- controller: boolean;
19
- };
20
- export type ControllerProvider = {
21
- /**
22
- * The function Jimpex calls when
23
- * registering the provider and the one
24
- * that has to generate the controller.
25
- */
26
- register: import('../types').ControllerProviderRegisterFn;
27
- };
28
- export type MiddlewareLike =
29
- | import('../types').Middleware
30
- | express.RequestHandler<
31
- import('express-serve-static-core').ParamsDictionary,
32
- any,
33
- any,
34
- qs.ParsedQs,
35
- Record<string, any>
36
- >
37
- | express.ErrorRequestHandler<
38
- import('express-serve-static-core').ParamsDictionary,
39
- any,
40
- any,
41
- qs.ParsedQs,
42
- Record<string, any>
43
- >;
44
- export type Server = import('http').Server | https.Server;
45
- export type JimpexStartCallback = (
46
- appConfiguration: import('wootils/esm/node/appConfiguration').AppConfiguration,
47
- ) => any;
48
- export type JimpexOptions = {
49
- /**
50
- * The app version. To be used on the configuration. Default `'0.0.0'`.
51
- */
52
- version: string;
53
- /**
54
- * The size limit for the requests payload. Default `'15MB'`.
55
- */
56
- filesizeLimit: string;
57
- /**
58
- * Whether or not to automatically call the `boot` method after initialization.
59
- * Default `true`.
60
- */
61
- boot: boolean;
62
- /**
63
- * Whether or not to enable the proxy mode, so all providers, controllers and middlewares
64
- * will receive a proxied reference of the container, in which they can set and get
65
- * resources using dot notation.
66
- */
67
- proxy: boolean;
68
- /**
69
- * The options for the app configuration service.
70
- */
71
- configuration: import('../types').JimpexConfigurationOptions;
72
- /**
73
- * The options for the app static `middleware`.
74
- */
75
- statics: import('../types').JimpexStaticsOptions;
76
- /**
77
- * The options for the Express app.
78
- */
79
- express: import('../types').JimpexExpressOptions;
80
- /**
81
- * To tell the app which services should be registered when instantiated.
82
- */
83
- defaultServices: import('../types').JimpexDefaultServicesOptions;
84
- };
85
- /**
86
- * Jimpex is a mix of Jimple, a Javascript port of Pimple dependency injection container,
87
- * and Express, one of the most popular web frameworks for Node.
88
- *
89
- * @augments Jimple
90
- * @parent module:core
91
- * @todo Implement `helmet`.
92
- */
93
- export class Jimpex extends Jimple {
94
- /**
95
- * @param {Partial<JimpexOptions>} [options={}]
96
- * Preferences to customize the application.
97
- * @param {?Object} [configuration=null]
98
- * The default configuration for the `appConfiguration` service.
99
- */
100
- constructor(options?: Partial<JimpexOptions>, configuration?: any | null);
101
- /**
102
- * The application options.
103
- *
104
- * @type {JimpexOptions}
105
- * @access protected
106
- * @ignore
107
- */
108
- _options: JimpexOptions;
109
- /**
110
- * If the `proxy` option was set to `true`, this property will have a reference for a
111
- * proxy of the container, in which resources can be registered and obtained using dot
112
- * notation.
113
- *
114
- * @type {?Proxy<Jimpex>}
115
- * @access protected
116
- * @ignore
117
- */
118
- _proxy: ProxyConstructor | null;
119
- /**
120
- * The Express application Jimpex uses under the hood.
121
- *
122
- * @type {Express}
123
- * @access protected
124
- * @ignore
125
- */
126
- _express: Express;
127
- /**
128
- * When Jimpex is used with HTTP2 enabled, this property will be used to store the
129
- * "patched"
130
- * version of Express that uses Spdy.
131
- *
132
- * @type {?SpdyServer}
133
- * @access protected
134
- * @ignore
135
- */
136
- _spdy: SpdyServer | null;
137
- /**
138
- * When the application starts, this will be the instance of the server.
139
- *
140
- * @type {?Server}
141
- * @access protected
142
- * @ignore
143
- */
144
- _instance: Server | null;
145
- /**
146
- * A list of functions that return controllers and middlewares. When the application
147
- * starts,
148
- * the queue will be processed and those controllers and middlewares will be added to
149
- * the server instance The reason they are not added directly like with a regular
150
- * Express implementation is that services on Jimple use lazy loading, and adding
151
- * middlewares and controllers as they come could cause errors if they depend on
152
- * services that are not yet registered.
153
- *
154
- * @type {Function[]}
155
- * @access protected
156
- * @ignore
157
- */
158
- _mountQueue: Function[];
159
- /**
160
- * A list with all the top routes controlled by the application. Every time a
161
- * controller is mounted, its route will be added here.
162
- *
163
- * @type {string[]}
164
- * @access protected
165
- * @ignore
166
- */
167
- _controlledRoutes: string[];
168
- /**
169
- * This is where the app would register all its specific services, middlewares and controllers.
170
- */
171
- boot(): void;
172
- /**
173
- * Disables the server TLS validation.
174
- */
175
- disableTLSValidation(): void;
176
- /**
177
- * This is an alias of `start`. The idea is for it to be used on serverless platforms,
178
- * where you don't get to start your app, you just have export it.
179
- *
180
- * @param {?number} [port=null] In case the configuration doesn't
181
- * already have it,
182
- * this is the port where the application
183
- * will use to run. If this parameter is
184
- * used, the method will overwrite the
185
- * `port`
186
- * setting on the configuration service.
187
- * @param {?JimpexStartCallback} [fn=null] A callback function to be called when
188
- * the server starts.
189
- * @returns {Server} The server instance.
190
- */
191
- listen(port?: number | null, fn?: JimpexStartCallback | null): Server;
192
- /**
193
- * Mounts a controller on a specific route.
194
- *
195
- * @param {string} route
196
- * The route for the controller.
197
- * @param {Controller | ControllerProvider} controller
198
- * The route controller.
199
- */
200
- mount(route: string, controller: Controller | ControllerProvider): void;
201
- /**
202
- * Gets "safe" reference for the container that validates if the "proxy mode" is
203
- * enabled, in order to provide the proxy or the actual instance.
204
- *
205
- * @returns {Jimpex}
206
- */
207
- ref(): Jimpex;
208
- /**
209
- * Registers a provider to extend the application.
210
- *
211
- * @param {Provider} provider The provider to register.
212
- */
213
- register(provider: Provider): void;
214
- /**
215
- * Starts the app server.
216
- *
217
- * @param {?JimpexStartCallback} [fn=null] A callback function to be called when the
218
- * server starts.
219
- * @returns {Object} The server instance.
220
- */
221
- start(fn?: JimpexStartCallback | null): any;
222
- _server: import('../types').Server;
223
- /**
224
- * Stops the server instance.
225
- */
226
- stop(): void;
227
- /**
228
- * Tries to access a resource on the container, but if is not present, it won't throw
229
- * an error,
230
- * it will just return `null`.
231
- *
232
- * @param {string} name The name of the resource.
233
- * @returns {*}
234
- * @throws {Error} If there's an error other than the one generated when the
235
- * resource doesn't exist.
236
- */
237
- try(name: string): any;
238
- /**
239
- * Adds a middleware.
240
- *
241
- * @param {MiddlewareLike} middleware The middleware to use.
242
- */
243
- use(middleware: MiddlewareLike): void;
244
- /**
245
- * The Express app Jimpex uses under the hood.
246
- *
247
- * @type {Express}
248
- */
249
- get express(): express.Express;
250
- /**
251
- * The server instance that gets created when the app is started.
252
- *
253
- * @returns {?Server}
254
- */
255
- get instance(): import('../types').Server;
256
- /**
257
- * The app options.
258
- *
259
- * @type {JimpexOptions}
260
- */
261
- get options(): import('../types').JimpexOptions;
262
- /**
263
- * A list of all the top routes controlled by the app.
264
- *
265
- * @type {string[]}
266
- */
267
- get routes(): string[];
268
- /**
269
- * Helper method to add static folders to the app.
270
- *
271
- * @param {string} route The route for the static folder.
272
- * @param {string} [folder=''] The path to the folder. If not defined, it will
273
- * use the value from `route`.
274
- * @param {boolean} [onHome=false] If `true`, the path to the folder will be relative
275
- * to where the app is being executed
276
- * (`process.cwd()`), otherwise, it will be relative
277
- * to where the executable file is located.
278
- * @access protected
279
- * @ignore
280
- */
281
- _addStaticsFolder(route: string, folder?: string, onHome?: boolean): void;
282
- /**
283
- * Emits an app event with a reference to this class instance.
284
- *
285
- * @param {string} name The name of the event on {@link JimpexEvents}.
286
- * @param {...*} args Extra parameters for the listeners.
287
- * @access protected
288
- * @ignore
289
- */
290
- _emitEvent(name: string, ...args: any[]): void;
291
- /**
292
- * Validates the configuration and chooses the server the application needs to use: If
293
- * HTTP2 is enabled, it will use Spdy; if HTTP is enabled but HTTP is not, it will use
294
- * the native HTTPS server; otherwise, it will be just the Express instance.
295
- *
296
- * @returns {Server}
297
- * @throws {Error} If HTTP2 is enabled but HTTPS is not.
298
- * @throws {Error} If HTTPS is enabled but there's no `https.credentials` object.
299
- * @throws {Error} If HTTPS is enabled and no creadentials are found.
300
- * @access protected
301
- * @ignore
302
- */
303
- _getServer(): Server;
304
- /**
305
- * This method is like a "lifecycle method", it gets executed on the constructor right
306
- * before the "boot step". The idea is for the method to be a helper when application
307
- * is defined by subclassing {@link Jimpex}: the application could register all
308
- * important services here and the routes on boot, then, if the implementation needs
309
- * to access or overwrite a something, it can send `boot: false`, access/register what
310
- * it needs and then call `boot()`. That would be impossible for an application
311
- * without overwriting the constructor and the boot functionality.
312
- *
313
- * @access protected
314
- */
315
- _init(): void;
316
- /**
317
- * It generates overwrites for the class options when they are created. This method is
318
- * a helper for when the application is defined by subclassing {@link Jimpex}: It's
319
- * highly probable that if the application needs to change the default options, it
320
- * would want to do it right from the class, instead of having to do it on every
321
- * implementation. A way to do it would be overwriting the constructor and calling
322
- * `super` with the custom overwrites; this method exists so that won't be necessary:
323
- * when creating the `options`, the constructor will merge the result of this method
324
- * on top of the default ones.
325
- *
326
- * @returns {Partial<JimpexOptions>}
327
- * @access protected
328
- */
329
- _initOptions(): Partial<JimpexOptions>;
330
- /**
331
- * Loads the contents of a dictionary of files that need to be used for HTTPS
332
- * credentials.
333
- *
334
- * @param {boolean} onHome
335
- * If this is `true`, the path of the files will be relative to the project root
336
- * directory;
337
- * otherwise, it will be relative to the directory where the application executable is
338
- * located.
339
- * @param {Object.<string, string>} credentialsInfo
340
- * The dictionary where the keys are the type of credentials (`ca`,
341
- * `cert` and/or `key`) and the values the paths to the files.
342
- * @returns {Object.<string, string>}
343
- * @access protected
344
- * @ignore
345
- */
346
- _loadCredentials(
347
- onHome: boolean,
348
- credentialsInfo: {
349
- [x: string]: string;
350
- },
351
- ): {
352
- [x: string]: string;
353
- };
354
- /**
355
- * Processes and mount all the resources on the `mountQueue`.
356
- *
357
- * @access protected
358
- * @ignore
359
- */
360
- _mountResources(): void;
361
- /**
362
- * Sends a target object to a list of reducer events so they can modify or replace it.
363
- * This method also sends a reference to this class instance as the last parameter of
364
- * the event.
365
- *
366
- * @param {string} name The name of the event on {@link JimpexEvents}.
367
- * @param {*} target The targe object to reduce.
368
- * @param {...*} args Extra parameters for the listeners.
369
- * @returns {*} An object of the same type as the `target`.
370
- * @access protected
371
- * @ignore
372
- */
373
- _reduceWithEvent(name: string, target: any, ...args: any[]): any;
374
- /**
375
- * Creates the configuration service.
376
- *
377
- * @access protected
378
- * @ignore
379
- */
380
- _setupConfiguration(): void;
381
- /**
382
- * Registers the _'core services'_.
383
- *
384
- * @access protected
385
- * @ignore
386
- */
387
- _setupCoreServices(): void;
388
- /**
389
- * Based on the constructor received options, register or not the default services.
390
- *
391
- * @access protected
392
- * @ignore
393
- */
394
- _setupDefaultServices(): void;
395
- /**
396
- * Creates and configure the Express instance.
397
- *
398
- * @access protected
399
- * @ignore
400
- */
401
- _setupExpress(): void;
402
- }
403
- /**
404
- * Creates a new instance of {@link Jimpex}.
405
- *
406
- * @param {Partial<JimpexOptions>} [options={}]
407
- * Preferences to customize the application.
408
- * @param {?Object} [configuration=null]
409
- * The default configuration for the `appConfiguration` service.
410
- * @returns {Jimpex}
411
- */
412
- export function jimpex(
413
- options?: Partial<JimpexOptions>,
414
- configuration?: any | null,
415
- ): Jimpex;
416
- import express = require('express');
417
- import https = require('https');
@@ -1,93 +0,0 @@
1
- export = eventNames;
2
- /**
3
- * The name of all the events {@link Jimpex} can trigger.
4
- *
5
- * @typedef {Object} JimpexEvents
6
- * @property {string} beforeStop Called before closing the instance of the
7
- * app.
8
- * @property {string} start Called from the `listen` callback, when the
9
- * app is ready to be used.
10
- * @property {string} afterStart Called from the `listen` callback, when all
11
- * controllers and middlewares have been
12
- * mounted.
13
- * @property {string} afterStartCallback Called right after the callback sent to
14
- * `start`
15
- * gets executed.
16
- * @property {string} beforeStart Called before `listen` is executed on the
17
- * Express app.
18
- * @property {string} afterStop Called after the app instance has been
19
- * closed and deleted.
20
- * @property {string} routeAdded Called every time a new route is added to
21
- * the app.
22
- * @property {string} controllerWillBeMounted This is for a reducer event. It gets called
23
- * before mounting a router or a set of routes
24
- * to the app in order to "reduce it".
25
- * @property {string} middlewareWillBeUsed This is for a reducer event. It gets called
26
- * before using a middleware in order to
27
- * "reduce it".
28
- * @parent module:constants
29
- */
30
- /**
31
- * The name of all the events {@link Jimpex} can trigger.
32
- *
33
- * @type {JimpexEvents}
34
- * @parent module:constants
35
- */
36
- declare const eventNames: JimpexEvents;
37
- declare namespace eventNames {
38
- export { JimpexEvents };
39
- }
40
- /**
41
- * The name of all the events {@link Jimpex } can trigger.
42
- */
43
- type JimpexEvents = {
44
- /**
45
- * Called before closing the instance of the
46
- * app.
47
- */
48
- beforeStop: string;
49
- /**
50
- * Called from the `listen` callback, when the
51
- * app is ready to be used.
52
- */
53
- start: string;
54
- /**
55
- * Called from the `listen` callback, when all
56
- * controllers and middlewares have been
57
- * mounted.
58
- */
59
- afterStart: string;
60
- /**
61
- * Called right after the callback sent to
62
- * `start`
63
- * gets executed.
64
- */
65
- afterStartCallback: string;
66
- /**
67
- * Called before `listen` is executed on the
68
- * Express app.
69
- */
70
- beforeStart: string;
71
- /**
72
- * Called after the app instance has been
73
- * closed and deleted.
74
- */
75
- afterStop: string;
76
- /**
77
- * Called every time a new route is added to
78
- * the app.
79
- */
80
- routeAdded: string;
81
- /**
82
- * This is for a reducer event. It gets called
83
- * before mounting a router or a set of routes
84
- * to the app in order to "reduce it".
85
- */
86
- controllerWillBeMounted: string;
87
- /**
88
- * This is for a reducer event. It gets called
89
- * before using a middleware in order to
90
- * "reduce it".
91
- */
92
- middlewareWillBeUsed: string;
93
- };
@@ -1,2 +0,0 @@
1
- export { eventNames };
2
- import eventNames = require("./eventNames");
@@ -1,71 +0,0 @@
1
- export type ExpressMiddleware = import('../../types').ExpressMiddleware;
2
- export type ExpressResponse = import('../../types').ExpressResponse;
3
- export type AppConfiguration = import('../../types').AppConfiguration;
4
- export type ResponsesBuilder = import('../../services/http/responsesBuilder').ResponsesBuilder;
5
- export type Controller = import('../../types').Controller;
6
- /**
7
- * @typedef {import('../../types').ExpressMiddleware} ExpressMiddleware
8
- * @typedef {import('../../types').ExpressResponse} ExpressResponse
9
- * @typedef {import('../../types').AppConfiguration} AppConfiguration
10
- * @typedef {import('../../services/http/responsesBuilder').ResponsesBuilder} ResponsesBuilder
11
- * @typedef {import('../../types').Controller} Controller
12
- * @prettierignore
13
- */
14
- /**
15
- * Provides the handlers and middlwares to show and switch configurations.
16
- *
17
- * @parent module:controllers
18
- */
19
- export class ConfigurationController {
20
- /**
21
- * @param {AppConfiguration} appConfiguration To read the app configuration.
22
- * @param {ResponsesBuilder} responsesBuilder To generate the JSON responses.
23
- */
24
- constructor(appConfiguration: AppConfiguration, responsesBuilder: ResponsesBuilder);
25
- /**
26
- * A local reference for the `appConfiguration` service.
27
- *
28
- * @type {AppConfiguration}
29
- * @access protected
30
- * @ignore
31
- */
32
- _appConfiguration: AppConfiguration;
33
- /**
34
- * A local reference for the `responsesBuilder` service.
35
- *
36
- * @type {ResponsesBuilder}
37
- * @access protected
38
- * @ignore
39
- */
40
- _responsesBuilder: ResponsesBuilder;
41
- /**
42
- * Send a response with the current app configuration as a body.
43
- *
44
- * @param {ExpressResponse} res The server response.
45
- */
46
- getConfigurationResponse(res: ExpressResponse): void;
47
- /**
48
- * Returns the middleware to show the current configuration.
49
- *
50
- * @returns {ExpressMiddleware}
51
- */
52
- showConfiguration(): ExpressMiddleware;
53
- /**
54
- * Returns the middleware to switch the current configuration.
55
- *
56
- * @returns {ExpressMiddleware}
57
- */
58
- switchConfiguration(): ExpressMiddleware;
59
- }
60
- /**
61
- * This controller is kind of special as it will only mount the routes if the
62
- * `debug.configurationController` setting of the app configuration is `true`.
63
- * It provides routes for:
64
- * - Showing the current configuration.
65
- * - Switching the configuration, but only if the service allows it.
66
- *
67
- * @type {Controller}
68
- * @parent module:controllers
69
- * @todo Don't use an array to return the routes.
70
- */
71
- export const configurationController: Controller;
@@ -1,55 +0,0 @@
1
- export type ExpressMiddleware = import('../../types').ExpressMiddleware;
2
- export type AppConfiguration = import('../../types').AppConfiguration;
3
- export type Controller = import('../../types').Controller;
4
- export type ResponsesBuilder = import('../../services/http/responsesBuilder').ResponsesBuilder;
5
- /**
6
- * @typedef {import('../../types').ExpressMiddleware} ExpressMiddleware
7
- * @typedef {import('../../types').AppConfiguration} AppConfiguration
8
- * @typedef {import('../../types').Controller} Controller
9
- * @typedef {import('../../services/http/responsesBuilder').ResponsesBuilder} ResponsesBuilder
10
- * @prettierignore
11
- */
12
- /**
13
- * Provides the handler to show a some minimal health information about the app:
14
- * - app version.
15
- * - configuration name.
16
- *
17
- * @parent module:controllers
18
- */
19
- export class HealthController {
20
- /**
21
- * @param {AppConfiguration} appConfiguration To read the app version and the
22
- * configuration name.
23
- * @param {ResponsesBuilder} responsesBuilder To generate the JSON response.
24
- */
25
- constructor(appConfiguration: AppConfiguration, responsesBuilder: ResponsesBuilder);
26
- /**
27
- * A local reference for the `appConfiguration` service.
28
- *
29
- * @type {AppConfiguration}
30
- * @access protected
31
- * @ignore
32
- */
33
- _appConfiguration: AppConfiguration;
34
- /**
35
- * A local reference for the `responsesBuilder` service.
36
- *
37
- * @type {ResponsesBuilder}
38
- * @access protected
39
- * @ignore
40
- */
41
- _responsesBuilder: ResponsesBuilder;
42
- /**
43
- * Returns the middleware that shows the health information.
44
- *
45
- * @returns {ExpressMiddleware}
46
- */
47
- health(): ExpressMiddleware;
48
- }
49
- /**
50
- * Mounts the health route.
51
- *
52
- * @type {Controller}
53
- * @parent module:controllers
54
- */
55
- export const healthController: Controller;
@@ -1,4 +0,0 @@
1
- import { configurationController } from "./configuration";
2
- import { healthController } from "./health";
3
- import { staticsController } from "./statics";
4
- export { configurationController, healthController, staticsController };