jimpex 7.0.2 → 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 +80 -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,140 +0,0 @@
1
- export type Provider = import('../../types').Provider;
2
- export type AppConfiguration = import('../../types').AppConfiguration;
3
- export type ExpressResponse = import('../../types').ExpressResponse;
4
- /**
5
- * It allows customization of a post message HTML template.
6
- */
7
- export type ResponsesBuilderPostMessageOptions = {
8
- /**
9
- * The target that will emit the `postMessage`.
10
- * Default `'window.opener'`.
11
- */
12
- target: string | null;
13
- /**
14
- * Whether or not to do a `window.close` after sending the message.
15
- * Default `true`.
16
- */
17
- close: boolean | null;
18
- /**
19
- * How many ms should it wait before closing the window, if `options.close` is `true`.
20
- * Default `700`.
21
- */
22
- closeDelay: number | null;
23
- };
24
- /**
25
- * @typedef {import('../../types').Provider} Provider
26
- * @typedef {import('../../types').AppConfiguration} AppConfiguration
27
- * @typedef {import('../../types').ExpressResponse} ExpressResponse
28
- */
29
- /**
30
- * It allows customization of a post message HTML template.
31
- *
32
- * @typedef {Object} ResponsesBuilderPostMessageOptions
33
- * @property {?string} target
34
- * The target that will emit the `postMessage`.
35
- * Default `'window.opener'`.
36
- * @property {?boolean} close
37
- * Whether or not to do a `window.close` after sending the message.
38
- * Default `true`.
39
- * @property {?number} closeDelay
40
- * How many ms should it wait before closing the window, if `options.close` is `true`.
41
- * Default `700`.
42
- * @parent module:services
43
- */
44
- /**
45
- * A utility service to build server responses.
46
- *
47
- * @parent module:services
48
- */
49
- export class ResponsesBuilder {
50
- /**
51
- * @param {AppConfiguration} appConfiguration To get the app version.
52
- */
53
- constructor(appConfiguration: AppConfiguration);
54
- /**
55
- * A local reference for the `appConfiguration` service.
56
- *
57
- * @type {AppConfiguration}
58
- * @access protected
59
- * @ignore
60
- */
61
- _appConfiguration: AppConfiguration;
62
- /**
63
- * Generates and send an HTML response that emits a post message.
64
- * The post message will be prefixed with the value of the configuration setting
65
- * `postMessagesPrefix`.
66
- *
67
- * @param {ExpressResponse} res
68
- * The Express response object necessary to write the HTML.
69
- * @param {string} title
70
- * The title for the HTML.
71
- * @param {string} message
72
- * The contents of the post message.
73
- * @param {number} [status=200]
74
- * The HTTP status.
75
- * @param {Partial<ResponsesBuilderPostMessageOptions>} [options={}]
76
- * Options to customize the HTML.
77
- */
78
- htmlPostMessage(res: ExpressResponse, title: string, message: string, status?: number, options?: Partial<ResponsesBuilderPostMessageOptions>): void;
79
- /**
80
- * Generates and sends a JSON response.
81
- *
82
- * @example
83
- *
84
- * <caption>The generated looks like this.</caption>
85
- *
86
- * {
87
- * metadata: {
88
- * version: '[app-version]',
89
- * status: [http-status],
90
- * },
91
- * data: [...],
92
- * }
93
- *
94
- * @param {ExpressResponse} res The Express response object necessary to
95
- * write the JSON.
96
- * @param {Object} data The information for the `data` key.
97
- * @param {number} [status=200] The HTTP status.
98
- * @param {Object} [metadata={}] Extra information to include on the
99
- * `metadata` key.
100
- */
101
- json(res: ExpressResponse, data: any, status?: number, metadata?: any): void;
102
- /**
103
- * Generates a basic HTML template for other services to use.
104
- *
105
- * @param {string} title The HTML `<title />` attribute.
106
- * @param {string} code Javascript code to be wrapped on a `<script />` tag.
107
- * @returns {string}
108
- * @access protected
109
- * @ignore
110
- */
111
- _htmlTemplate(title: string, code: string): string;
112
- /**
113
- * Utility method used to make sure a recevied status is a valid status code. If the
114
- * status is a string, the method will try to find the code from the `statuses` package.
115
- *
116
- * @param {string | number} status The status to normalize.
117
- * @returns {string | number} If `status` is a string, but there's no valid code, it
118
- * will return it as it was received.
119
- * @access protected
120
- * @ignore
121
- * @todo On the next breaking version, if there's no valid code, it will be
122
- * transformed to `200`.
123
- */
124
- _normalizeStatus(status: string | number): string | number;
125
- }
126
- /**
127
- * The service provider that once registered on the app container will set an instance of
128
- * `ResponsesBuilder` as the `responsesBuilder` service.
129
- *
130
- * @type {Provider}
131
- * @example
132
- *
133
- * // Register it on the container
134
- * container.register(responsesBuilder);
135
- * // Getting access to the service instance
136
- * const responsesBuilder = container.get('responsesBuilder');
137
- *
138
- * @parent module:services
139
- */
140
- export const responsesBuilder: Provider;
@@ -1,6 +0,0 @@
1
- import common = require("./common");
2
- import frontend = require("./frontend");
3
- import html = require("./html");
4
- import http = require("./http");
5
- import utils = require("./utils");
6
- export { common, frontend, html, http, utils };
@@ -1,137 +0,0 @@
1
- export type ExpressMiddleware = import('../../types').ExpressMiddleware;
2
- /**
3
- * <O>
4
- */
5
- export type ProviderCreator<O> = import('../../types').ProviderCreator<O>;
6
- /**
7
- * These options allow you to modify the error generated by the middleware when the
8
- * request doesn't have a valid token.
9
- */
10
- export type EnsureBearerTokenErrorOptions = {
11
- /**
12
- * The error message for the response. Default
13
- * `'Unauthorized'`.
14
- */
15
- message: string;
16
- /**
17
- * The HTTP status that will be added to error context
18
- * information.
19
- * Default `401`.
20
- */
21
- status: number;
22
- /**
23
- * Context information that the error handler can read and
24
- * add to the default response. Default `{}`.
25
- */
26
- response: any;
27
- };
28
- /**
29
- * The options for how to validate the token and, possibly, create the errors.
30
- */
31
- export type EnsureBearerTokenOptions = {
32
- /**
33
- * The options to modify the error generated by the middleware when the request doesn't
34
- * have a valid token.
35
- */
36
- error: EnsureBearerTokenErrorOptions;
37
- /**
38
- * The regular expression used to extract the token from the request authorization header.
39
- */
40
- expression: RegExp;
41
- /**
42
- * The property inside the `res.locals` where the token, if found, will be saved.
43
- * Default `'token'`.
44
- */
45
- local: string;
46
- };
47
- /**
48
- * @typedef {import('../../types').ExpressMiddleware} ExpressMiddleware
49
- */
50
- /**
51
- * @typedef {import('../../types').ProviderCreator<O>} ProviderCreator<O>
52
- * @template O
53
- */
54
- /**
55
- * These options allow you to modify the error generated by the middleware when the
56
- * request doesn't have a valid token.
57
- *
58
- * @typedef {Object} EnsureBearerTokenErrorOptions
59
- * @property {string} message The error message for the response. Default
60
- * `'Unauthorized'`.
61
- * @property {number} status The HTTP status that will be added to error context
62
- * information.
63
- * Default `401`.
64
- * @property {Object} response Context information that the error handler can read and
65
- * add to the default response. Default `{}`.
66
- * @parent module:services
67
- */
68
- /**
69
- * The options for how to validate the token and, possibly, create the errors.
70
- *
71
- * @typedef {Object} EnsureBearerTokenOptions
72
- * @property {EnsureBearerTokenErrorOptions} error
73
- * The options to modify the error generated by the middleware when the request doesn't
74
- * have a valid token.
75
- * @property {RegExp} expression
76
- * The regular expression used to extract the token from the request authorization header.
77
- * @property {string} local
78
- * The property inside the `res.locals` where the token, if found, will be saved.
79
- * Default `'token'`.
80
- * @parent module:services
81
- */
82
- /**
83
- * This service gives you a middleware that verifies if a request has an `Authorization`
84
- * header with a bearer token; if it does, the token will be saved on the `res.locals`,
85
- * otherwise, it will generate an error.
86
- *
87
- * @parent module:services
88
- */
89
- export class EnsureBearerToken {
90
- /**
91
- * @param {ClassAppError} AppError
92
- * To format the error caused when the request doesn't have a valid token.
93
- * @param {Partial<EnsureBearerTokenOptions>} [options={}]
94
- * The options to customize the middleware behavior: how to validate the token, how to
95
- * save it and what kind of error should generate.
96
- */
97
- constructor(AppError: any, options?: Partial<EnsureBearerTokenOptions>);
98
- /**
99
- * A local reference for the class the app uses to generate errors.
100
- *
101
- * @type {ClassAppError}
102
- * @access protected
103
- * @ignore
104
- */
105
- _AppError: any;
106
- /**
107
- * The options that define how the middleware validates the token, saves it and
108
- * generates the possible error.
109
- *
110
- * @type {EnsureBearerTokenOptions}
111
- * @access protected
112
- * @ignore
113
- */
114
- _options: EnsureBearerTokenOptions;
115
- /**
116
- * Creates the middleware that will validate the presence of a bearer token on the
117
- * request authorization header.
118
- *
119
- * @returns {ExpressMiddleware}
120
- */
121
- middleware(): ExpressMiddleware;
122
- /**
123
- * The options that define how the middleware validates the token, saves it and
124
- * generates the possible error.
125
- *
126
- * @type {EnsureBearerTokenOptions}
127
- */
128
- get options(): EnsureBearerTokenOptions;
129
- }
130
- /**
131
- * Generates a "service middleware" that can be used on route controllers in order to
132
- * validate the presence of a bearer token on the requests authorization header.
133
- *
134
- * @type {ProviderCreator<EnsureBearerTokenOptions>}
135
- * @parent module:services
136
- */
137
- export const ensureBearerToken: ProviderCreator<EnsureBearerTokenOptions>;
@@ -1,16 +0,0 @@
1
- export = utilsServices;
2
- /**
3
- * @typedef {import('../../types').Provider} Provider
4
- */
5
- /**
6
- * The providers collection for the utility services.
7
- *
8
- * @type {Provider}
9
- * @property {Provider} ensureBearerToken The provider for {@link EnsureBearerToken}.
10
- * @parent module:services
11
- */
12
- declare const utilsServices: Provider;
13
- declare namespace utilsServices {
14
- export { Provider };
15
- }
16
- type Provider = import('../../types').Provider;
package/types/types.d.ts DELETED
@@ -1,280 +0,0 @@
1
- export type Jimple = any;
2
- export type AppConfiguration = import('wootils/esm/node/appConfiguration').AppConfiguration;
3
- export type APIClientBase = import('wootils/esm/shared/apiClient');
4
- export type APIClientEndpoints = import('wootils/esm/shared/apiClient').APIClientEndpoints;
5
- export type PathUtils = import('wootils/esm/node/pathUtils').PathUtils;
6
- export type Logger = import('wootils/esm/node/logger').Logger;
7
- export type EnvironmentUtils = import('wootils/esm/node/environmentUtils').EnvironmentUtils;
8
- export type EventsHub = import('wootils/esm/shared/eventsHub');
9
- export type Provider = import('wootils/esm/shared/jimpleFns').Provider;
10
- export type Providers = import('wootils/esm/shared/jimpleFns').Providers;
11
- /**
12
- * <O>
13
- */
14
- export type ProviderCreator<O> = import('wootils/esm/shared/jimpleFns').ProviderCreator<O>;
15
- export type Express = import('express').Express;
16
- export type HTTPServer = import('http').Server;
17
- export type SpdyServer = import('spdy').Server;
18
- export type SpdyOptions = import('spdy').ServerOptions;
19
- export type Server = HTTPServer | SpdyServer;
20
- export type RequestHandler = import('express').RequestHandler;
21
- export type ErrorRequestHandler = import('express').ErrorRequestHandler;
22
- export type ExpressMiddleware = RequestHandler | ErrorRequestHandler;
23
- export type ExpressRequest = import('express').Request;
24
- export type ExpressResponse = import('express').Response;
25
- export type ExpressNext = import('express').NextFunction;
26
- export type ExpressRouter = import('express').Router;
27
- export type ClassHTTPError = typeof import("./services/common/httpError")['HTTPError'];
28
- export type ClassAppError = typeof import("./services/common/appError")['AppError'];
29
- export type Jimpex = import('./app').Jimpex;
30
- export type JimpexStartCallback = (appConfiguration: AppConfiguration) => any;
31
- export type JimpexConfigurationOptions = {
32
- /**
33
- * The app default configuration.
34
- * Default `null`.
35
- */
36
- default: any | null;
37
- /**
38
- * The name of the app, used for the
39
- * configuration files. Default `'app'`.
40
- */
41
- name: string;
42
- /**
43
- * The path to the configuration files
44
- * directory,
45
- * relative to the project root
46
- * directory. Default `'config/'`.
47
- */
48
- path: string;
49
- /**
50
- * Whether the configurations are inside
51
- * a sub directory or not. If `true`, a
52
- * configuration path would be
53
- * `config/[app-name]/[file]`.
54
- * Default `true`.
55
- */
56
- hasFolder: boolean;
57
- /**
58
- * The name of the environment variable
59
- * that will be used to set the active
60
- * configuration.
61
- * Default `'CONFIG'`.
62
- */
63
- environmentVariable: string;
64
- /**
65
- * Whether or not to check for the
66
- * environment variable and load a
67
- * configuration based on its value.
68
- * Default `true`.
69
- */
70
- loadFromEnvironment: boolean;
71
- /**
72
- * If `true`, the app `version` will be
73
- * taken from the loaded configuration,
74
- * otherwise, when a configuration is
75
- * loaded, the app will copy the version
76
- * it has into the configuration.
77
- * Default `true`.
78
- */
79
- loadVersionFromConfiguration: boolean;
80
- /**
81
- * The name format the configuration
82
- * files have.
83
- * Default:
84
- *
85
- *
86
- * `[app-name].[configuration-name].config.js`.
87
- */
88
- filenameFormat: string;
89
- };
90
- export type JimpexStaticsOptions = {
91
- /**
92
- * Whether or not to include the middleware for static files.
93
- * Default `true`.
94
- */
95
- enabled: boolean;
96
- /**
97
- * If `true`, the path to the statics folder will be relative
98
- * to the project root directory, otherwise, it will be
99
- * relative to the directory where the app executable file is
100
- * located. Default `false`.
101
- */
102
- onHome: boolean;
103
- /**
104
- * The name of both the route and the folder, relative to
105
- * whatever you defined with the `onHome` option. Default
106
- * `'static'`.
107
- */
108
- route: string;
109
- /**
110
- * By default, the folder will be the same as the `route`,
111
- * but you can use this option to define a relative path that
112
- * won't affect the route. Default `''`.
113
- */
114
- folder: string;
115
- };
116
- export type JimpexExpressOptions = {
117
- /**
118
- * Whether or not to enable the `trust proxy`
119
- * option.
120
- * Default `true`.
121
- */
122
- trustProxy: boolean;
123
- /**
124
- * Whether or not to remove the `x-powered-by`
125
- * header.
126
- * Default `true`.
127
- */
128
- disableXPoweredBy: boolean;
129
- /**
130
- * Whether or not to add the `compression`
131
- * middleware.
132
- * Default `true`.
133
- */
134
- compression: boolean;
135
- /**
136
- * Whether or not to add the `body-parser`
137
- * middleware.
138
- * Default `true`.
139
- */
140
- bodyParser: boolean;
141
- /**
142
- * Whether or not to add the `multer` middleware.
143
- * Default `true`.
144
- */
145
- multer: boolean;
146
- };
147
- export type JimpexDefaultServicesOptions = {
148
- /**
149
- * Whether or not to register all the `common` service
150
- * providers.
151
- * Default `true`.
152
- */
153
- common: boolean;
154
- /**
155
- * Whether or not to register all the `http` service
156
- * providers.
157
- * Default `true`.
158
- */
159
- http: boolean;
160
- /**
161
- * Whether or not to register all the `utils` service
162
- * providers.
163
- * Default `true`.
164
- */
165
- utils: boolean;
166
- };
167
- export type JimpexOptions = {
168
- /**
169
- * The app version. To be used on the configuration. Default `'0.0.0'`.
170
- */
171
- version: string;
172
- /**
173
- * The size limit for the requests payload. Default `'15MB'`.
174
- */
175
- filesizeLimit: string;
176
- /**
177
- * Whether or not to automatically call the `boot` method after initialization.
178
- * Default `true`.
179
- */
180
- boot: boolean;
181
- /**
182
- * Whether or not to enable the proxy mode, so all providers, controllers and middlewares
183
- * will receive a proxied reference of the container, in which they can set and get
184
- * resources using dot notation.
185
- */
186
- proxy: boolean;
187
- /**
188
- * The options for the app configuration service.
189
- */
190
- configuration: JimpexConfigurationOptions;
191
- /**
192
- * The options for the app static `middleware`.
193
- */
194
- statics: JimpexStaticsOptions;
195
- /**
196
- * The options for the Express app.
197
- */
198
- express: JimpexExpressOptions;
199
- /**
200
- * To tell the app which services should be registered when instantiated.
201
- */
202
- defaultServices: JimpexDefaultServicesOptions;
203
- };
204
- /**
205
- * An object that when mounted on Jimpex will take care of handling a list of specific
206
- * routes. The method Jimpex uses to mount a controller is {@link Jimpexmount }.
207
- */
208
- export type Controller = {
209
- /**
210
- * The function Jimpex calls when mounting the
211
- * controller.
212
- */
213
- connect: ControllerConnectFn;
214
- /**
215
- * A flag set to `true` to identify the
216
- * resource as a routes controller.
217
- */
218
- controller: boolean;
219
- };
220
- export type ControllerProviderRegisterFn = (app: Jimpex, route: string) => Controller;
221
- /**
222
- * This is a special kind of controller that not only registers routes but also adds
223
- * resources to the container, and to avoid doing it during the mount process, it
224
- * registers the resources first and then returns the actuall controller.
225
- */
226
- export type ControllerProvider = {
227
- /**
228
- * The function Jimpex calls when
229
- * registering the provider and the one
230
- * that has to generate the controller.
231
- */
232
- register: ControllerProviderRegisterFn;
233
- };
234
- /**
235
- * The function called by the application container in order to mount a routes controller.
236
- */
237
- export type ControllerConnectFn = (app: Jimpex, route: string) => any;
238
- /**
239
- * A function called in order to generate a {@link Controller }. They usually have
240
- * different options that will be sent to the controller creation.
241
- */
242
- export type ControllerCreatorFn = () => ControllerConnectFn;
243
- /**
244
- * A special kind of {@link Controller } that can be used with {@link Jimpexmount } as a
245
- * regular controller, or it can be called as a function with custom parameters in order
246
- * to obtain a "configured {@link Controller }".
247
- */
248
- export type ControllerCreator<O> = (options?: Partial<O>) => Controller | ControllerProvider;
249
- /**
250
- * An object that when mounted on Jimpex add an {@link ExpressMiddleware } to the app. The
251
- * method Jimpex uses to mount a middleware is {@link Jimpexuse }.
252
- */
253
- export type Middleware = {
254
- /**
255
- * The function Jimpex calls when mounting the
256
- * middleware.
257
- */
258
- connect: MiddlewareConnectFn;
259
- /**
260
- * A flag set to `true` to identify the
261
- * resource as a middleware.
262
- */
263
- middleware: boolean;
264
- };
265
- /**
266
- * The function called by the application container in order to use a middleware.
267
- */
268
- export type MiddlewareConnectFn = (app: Jimpex) => ExpressMiddleware | null;
269
- /**
270
- * A function called in order to generate a {@link Middleware }. They usually have
271
- * different options that will be sent to the middleware creation.
272
- */
273
- export type MiddlewareCreatorFn = () => MiddlewareConnectFn;
274
- /**
275
- * A special kind of {@link Middleware } that can be used with {@link Jimpexuse } as a
276
- * regular middleware, or it can be called as a function with custom parameters in order
277
- * to obtain a "configured {@link Middleware }".
278
- */
279
- export type MiddlewareCreator<O> = (options?: Partial<O>) => Middleware;
280
- export type MiddlewareLike = Middleware | ExpressMiddleware;
@@ -1,55 +0,0 @@
1
- /**
2
- * Given a server route definition, this function creates a regular expression to match
3
- * it: The expression replaces the routes parameters with placeholders so it can be
4
- * compared with real routes.
5
- *
6
- * @param {string} route The route from which the expression will be
7
- * created.
8
- * @param {boolean} [leadingSlash=true] Whether or not the expression should match a
9
- * leading slash.
10
- * @param {boolean} [trailingSlash=false] Whether or not the expression should match a
11
- * trailing slash. The reason this is `false` by
12
- * default is because these expressions are often
13
- * used to match against incoming requests, and
14
- * they don't have a trailing slash.
15
- * @returns {RegExp}
16
- * @parent module:functions
17
- */
18
- export function createRouteExpression(route: string, leadingSlash?: boolean, trailingSlash?: boolean): RegExp;
19
- /**
20
- * Escapes a string to be used on `new RegExp(...)`.
21
- *
22
- * @param {string} text The text to escape.
23
- * @returns {string}
24
- * @parent module:functions
25
- */
26
- export function escapeForRegExp(text: string): string;
27
- /**
28
- * @module functions
29
- */
30
- /**
31
- * Removes any leading slash from a URL.
32
- *
33
- * @param {string} url The URL to format.
34
- * @returns {string}
35
- * @parent module:functions
36
- */
37
- export function removeLeadingSlash(url: string): string;
38
- /**
39
- * Remove any leading and trailing slash from a URL.
40
- *
41
- * @param {string} url The URL to format.
42
- * @param {boolean} [leading=true] Whether or not to remove any leading slash.
43
- * @param {boolean} [trailing=true] Whether or not to remove the trailing slash.
44
- * @returns {string}
45
- * @parent module:functions
46
- */
47
- export function removeSlashes(url: string, leading?: boolean, trailing?: boolean): string;
48
- /**
49
- * Removes any trailing slash from a URL.
50
- *
51
- * @param {string} url The URL to format.
52
- * @returns {string}
53
- * @parent module:functions
54
- */
55
- export function removeTrailingSlash(url: string): string;