jimpex 10.0.2 → 11.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 (346) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +7 -9
  3. package/dist/app/index.d.ts +1 -1
  4. package/dist/app/index.js +1 -22
  5. package/dist/app/index.js.map +1 -1
  6. package/dist/app/jimpex.d.ts +1 -1
  7. package/dist/app/jimpex.js +100 -131
  8. package/dist/app/jimpex.js.map +1 -1
  9. package/dist/controllers/common/config.d.ts +2 -2
  10. package/dist/controllers/common/config.js +12 -39
  11. package/dist/controllers/common/config.js.map +1 -1
  12. package/dist/controllers/common/health.d.ts +4 -4
  13. package/dist/controllers/common/health.js +20 -47
  14. package/dist/controllers/common/health.js.map +1 -1
  15. package/dist/controllers/common/index.d.ts +1 -1
  16. package/dist/controllers/common/index.js +3 -26
  17. package/dist/controllers/common/index.js.map +1 -1
  18. package/dist/controllers/common/statics.d.ts +3 -3
  19. package/dist/controllers/common/statics.js +32 -65
  20. package/dist/controllers/common/statics.js.map +1 -1
  21. package/dist/controllers/index.d.ts +1 -1
  22. package/dist/controllers/index.js +2 -24
  23. package/dist/controllers/index.js.map +1 -1
  24. package/dist/controllers/utils/gateway.d.ts +5 -5
  25. package/dist/controllers/utils/gateway.js +70 -91
  26. package/dist/controllers/utils/gateway.js.map +1 -1
  27. package/dist/controllers/utils/index.d.ts +1 -1
  28. package/dist/controllers/utils/index.js +1 -22
  29. package/dist/controllers/utils/index.js.map +1 -1
  30. package/dist/{index-C6I3NCC-.d.ts → index-BlSpNHox.d.ts} +13 -13
  31. package/dist/index.d.ts +3 -3
  32. package/dist/index.js +6 -32
  33. package/dist/index.js.map +1 -1
  34. package/dist/middlewares/common/errorHandler.d.ts +5 -5
  35. package/dist/middlewares/common/errorHandler.js +31 -56
  36. package/dist/middlewares/common/errorHandler.js.map +1 -1
  37. package/dist/middlewares/common/forceHTTPS.d.ts +1 -1
  38. package/dist/middlewares/common/forceHTTPS.js +8 -35
  39. package/dist/middlewares/common/forceHTTPS.js.map +1 -1
  40. package/dist/middlewares/common/hsts.d.ts +1 -1
  41. package/dist/middlewares/common/hsts.js +12 -39
  42. package/dist/middlewares/common/hsts.js.map +1 -1
  43. package/dist/middlewares/common/index.d.ts +3 -3
  44. package/dist/middlewares/common/index.js +3 -26
  45. package/dist/middlewares/common/index.js.map +1 -1
  46. package/dist/middlewares/html/fastHTML.d.ts +4 -4
  47. package/dist/middlewares/html/fastHTML.js +43 -66
  48. package/dist/middlewares/html/fastHTML.js.map +1 -1
  49. package/dist/middlewares/html/index.d.ts +2 -2
  50. package/dist/middlewares/html/index.js +2 -24
  51. package/dist/middlewares/html/index.js.map +1 -1
  52. package/dist/middlewares/html/showHTML.d.ts +3 -3
  53. package/dist/middlewares/html/showHTML.js +25 -52
  54. package/dist/middlewares/html/showHTML.js.map +1 -1
  55. package/dist/middlewares/index.d.ts +4 -4
  56. package/dist/middlewares/index.js +3 -26
  57. package/dist/middlewares/index.js.map +1 -1
  58. package/dist/middlewares/utils/index.d.ts +3 -3
  59. package/dist/middlewares/utils/index.js +1 -22
  60. package/dist/middlewares/utils/index.js.map +1 -1
  61. package/dist/middlewares/utils/versionValidator.d.ts +5 -5
  62. package/dist/middlewares/utils/versionValidator.js +24 -51
  63. package/dist/middlewares/utils/versionValidator.js.map +1 -1
  64. package/dist/services/common/appError.d.ts +2 -2
  65. package/dist/services/common/appError.js +18 -46
  66. package/dist/services/common/appError.js.map +1 -1
  67. package/dist/services/common/httpError.d.ts +2 -2
  68. package/dist/services/common/httpError.js +7 -33
  69. package/dist/services/common/httpError.js.map +1 -1
  70. package/dist/services/common/index.d.ts +1 -1
  71. package/dist/services/common/index.js +14 -42
  72. package/dist/services/common/index.js.map +1 -1
  73. package/dist/services/common/sendFile.d.ts +1 -1
  74. package/dist/services/common/sendFile.js +4 -29
  75. package/dist/services/common/sendFile.js.map +1 -1
  76. package/dist/services/frontend/frontendFs.d.ts +2 -2
  77. package/dist/services/frontend/frontendFs.js +12 -49
  78. package/dist/services/frontend/frontendFs.js.map +1 -1
  79. package/dist/services/frontend/index.d.ts +2 -2
  80. package/dist/services/frontend/index.js +8 -34
  81. package/dist/services/frontend/index.js.map +1 -1
  82. package/dist/services/html/htmlGenerator.d.ts +5 -5
  83. package/dist/services/html/htmlGenerator.js +46 -75
  84. package/dist/services/html/htmlGenerator.js.map +1 -1
  85. package/dist/services/html/index.d.ts +2 -2
  86. package/dist/services/html/index.js +8 -34
  87. package/dist/services/html/index.js.map +1 -1
  88. package/dist/services/http/apiClient.d.ts +1 -1
  89. package/dist/services/http/apiClient.js +23 -48
  90. package/dist/services/http/apiClient.js.map +1 -1
  91. package/dist/services/http/http.d.ts +5 -5
  92. package/dist/services/http/http.js +23 -60
  93. package/dist/services/http/http.js.map +1 -1
  94. package/dist/services/http/index.d.ts +2 -2
  95. package/dist/services/http/index.js +14 -42
  96. package/dist/services/http/index.js.map +1 -1
  97. package/dist/services/http/responsesBuilder.d.ts +4 -4
  98. package/dist/services/http/responsesBuilder.js +13 -40
  99. package/dist/services/http/responsesBuilder.js.map +1 -1
  100. package/dist/services/index.d.ts +3 -3
  101. package/dist/services/index.js +5 -30
  102. package/dist/services/index.js.map +1 -1
  103. package/dist/services/utils/ensureBearerToken.d.ts +2 -2
  104. package/dist/services/utils/ensureBearerToken.js +15 -42
  105. package/dist/services/utils/ensureBearerToken.js.map +1 -1
  106. package/dist/services/utils/index.d.ts +1 -1
  107. package/dist/services/utils/index.js +8 -34
  108. package/dist/services/utils/index.js.map +1 -1
  109. package/dist/types/events.d.ts +1 -1
  110. package/dist/types/events.js +0 -16
  111. package/dist/types/events.js.map +1 -1
  112. package/dist/types/express.js +0 -16
  113. package/dist/types/express.js.map +1 -1
  114. package/dist/types/http.js +0 -16
  115. package/dist/types/http.js.map +1 -1
  116. package/dist/types/index.d.ts +1 -1
  117. package/dist/types/index.js +6 -32
  118. package/dist/types/index.js.map +1 -1
  119. package/dist/types/options.d.ts +1 -1
  120. package/dist/types/options.js +0 -16
  121. package/dist/types/options.js.map +1 -1
  122. package/dist/types/utils.js +0 -16
  123. package/dist/types/utils.js.map +1 -1
  124. package/dist/types/wootils.js +0 -16
  125. package/dist/types/wootils.js.map +1 -1
  126. package/dist/utils/fns/index.js +4 -28
  127. package/dist/utils/fns/index.js.map +1 -1
  128. package/dist/utils/fns/others.js +2 -26
  129. package/dist/utils/fns/others.js.map +1 -1
  130. package/dist/utils/fns/routes.js +4 -31
  131. package/dist/utils/fns/routes.js.map +1 -1
  132. package/dist/utils/fns/statuses.js +3 -37
  133. package/dist/utils/fns/statuses.js.map +1 -1
  134. package/dist/utils/fns/text.js +2 -26
  135. package/dist/utils/fns/text.js.map +1 -1
  136. package/dist/utils/index.d.ts +1 -1
  137. package/dist/utils/index.js +2 -24
  138. package/dist/utils/index.js.map +1 -1
  139. package/dist/utils/wrappers.d.ts +1 -1
  140. package/dist/utils/wrappers.js +20 -48
  141. package/dist/utils/wrappers.js.map +1 -1
  142. package/eslint.config.js +19 -0
  143. package/examples/basic/app.ts +4 -4
  144. package/examples/basic/controller.ts +2 -2
  145. package/examples/basic/index.ts +4 -4
  146. package/examples/basic/middleware.ts +2 -2
  147. package/examples/basic/service.ts +1 -1
  148. package/package.json +61 -49
  149. package/pnpm-workspace.yaml +4 -0
  150. package/src/app/index.ts +1 -1
  151. package/src/app/jimpex.ts +23 -20
  152. package/src/controllers/common/config.ts +4 -4
  153. package/src/controllers/common/health.ts +9 -5
  154. package/src/controllers/common/index.ts +3 -3
  155. package/src/controllers/common/statics.ts +12 -7
  156. package/src/controllers/index.ts +2 -2
  157. package/src/controllers/utils/gateway.ts +8 -8
  158. package/src/controllers/utils/index.ts +1 -1
  159. package/src/index.ts +6 -6
  160. package/src/middlewares/common/errorHandler.ts +9 -5
  161. package/src/middlewares/common/forceHTTPS.ts +2 -2
  162. package/src/middlewares/common/hsts.ts +2 -2
  163. package/src/middlewares/common/index.ts +3 -3
  164. package/src/middlewares/html/fastHTML.ts +14 -5
  165. package/src/middlewares/html/index.ts +2 -2
  166. package/src/middlewares/html/showHTML.ts +8 -4
  167. package/src/middlewares/index.ts +3 -3
  168. package/src/middlewares/utils/index.ts +1 -1
  169. package/src/middlewares/utils/versionValidator.ts +6 -6
  170. package/src/services/common/appError.ts +1 -1
  171. package/src/services/common/httpError.ts +2 -2
  172. package/src/services/common/index.ts +7 -7
  173. package/src/services/common/sendFile.ts +2 -2
  174. package/src/services/frontend/frontendFs.ts +3 -3
  175. package/src/services/frontend/index.ts +3 -3
  176. package/src/services/html/htmlGenerator.ts +11 -13
  177. package/src/services/html/index.ts +3 -3
  178. package/src/services/http/apiClient.ts +3 -3
  179. package/src/services/http/http.ts +5 -5
  180. package/src/services/http/index.ts +7 -7
  181. package/src/services/http/responsesBuilder.ts +5 -5
  182. package/src/services/index.ts +5 -5
  183. package/src/services/utils/ensureBearerToken.ts +4 -4
  184. package/src/services/utils/index.ts +3 -3
  185. package/src/types/events.ts +8 -8
  186. package/src/types/http.ts +1 -1
  187. package/src/types/index.ts +6 -6
  188. package/src/types/options.ts +2 -2
  189. package/src/types/utils.ts +4 -4
  190. package/src/utils/fns/index.ts +4 -4
  191. package/src/utils/fns/routes.ts +1 -1
  192. package/src/utils/index.ts +2 -2
  193. package/src/utils/wrappers.ts +6 -6
  194. package/tsconfig.json +9 -4
  195. package/tsup.config.ts +1 -2
  196. package/vitest.config.ts +24 -0
  197. package/dist/app/index.d.mts +0 -14
  198. package/dist/app/jimpex.d.mts +0 -14
  199. package/dist/controllers/common/config.d.mts +0 -79
  200. package/dist/controllers/common/health.d.mts +0 -83
  201. package/dist/controllers/common/index.d.mts +0 -22
  202. package/dist/controllers/common/statics.d.mts +0 -223
  203. package/dist/controllers/index.d.mts +0 -25
  204. package/dist/controllers/utils/gateway.d.mts +0 -725
  205. package/dist/controllers/utils/index.d.mts +0 -17
  206. package/dist/esm/app/index.js +0 -2
  207. package/dist/esm/app/index.js.map +0 -1
  208. package/dist/esm/app/jimpex.js +0 -640
  209. package/dist/esm/app/jimpex.js.map +0 -1
  210. package/dist/esm/chunk-V6TY7KAL.js +0 -8
  211. package/dist/esm/chunk-V6TY7KAL.js.map +0 -1
  212. package/dist/esm/controllers/common/config.js +0 -80
  213. package/dist/esm/controllers/common/config.js.map +0 -1
  214. package/dist/esm/controllers/common/health.js +0 -88
  215. package/dist/esm/controllers/common/health.js.map +0 -1
  216. package/dist/esm/controllers/common/index.js +0 -4
  217. package/dist/esm/controllers/common/index.js.map +0 -1
  218. package/dist/esm/controllers/common/statics.js +0 -226
  219. package/dist/esm/controllers/common/statics.js.map +0 -1
  220. package/dist/esm/controllers/index.js +0 -3
  221. package/dist/esm/controllers/index.js.map +0 -1
  222. package/dist/esm/controllers/utils/gateway.js +0 -559
  223. package/dist/esm/controllers/utils/gateway.js.map +0 -1
  224. package/dist/esm/controllers/utils/index.js +0 -2
  225. package/dist/esm/controllers/utils/index.js.map +0 -1
  226. package/dist/esm/index.js +0 -7
  227. package/dist/esm/index.js.map +0 -1
  228. package/dist/esm/middlewares/common/errorHandler.js +0 -116
  229. package/dist/esm/middlewares/common/errorHandler.js.map +0 -1
  230. package/dist/esm/middlewares/common/forceHTTPS.js +0 -52
  231. package/dist/esm/middlewares/common/forceHTTPS.js.map +0 -1
  232. package/dist/esm/middlewares/common/hsts.js +0 -74
  233. package/dist/esm/middlewares/common/hsts.js.map +0 -1
  234. package/dist/esm/middlewares/common/index.js +0 -4
  235. package/dist/esm/middlewares/common/index.js.map +0 -1
  236. package/dist/esm/middlewares/html/fastHTML.js +0 -157
  237. package/dist/esm/middlewares/html/fastHTML.js.map +0 -1
  238. package/dist/esm/middlewares/html/index.js +0 -3
  239. package/dist/esm/middlewares/html/index.js.map +0 -1
  240. package/dist/esm/middlewares/html/showHTML.js +0 -100
  241. package/dist/esm/middlewares/html/showHTML.js.map +0 -1
  242. package/dist/esm/middlewares/index.js +0 -4
  243. package/dist/esm/middlewares/index.js.map +0 -1
  244. package/dist/esm/middlewares/utils/index.js +0 -2
  245. package/dist/esm/middlewares/utils/index.js.map +0 -1
  246. package/dist/esm/middlewares/utils/versionValidator.js +0 -135
  247. package/dist/esm/middlewares/utils/versionValidator.js.map +0 -1
  248. package/dist/esm/services/common/appError.js +0 -98
  249. package/dist/esm/services/common/appError.js.map +0 -1
  250. package/dist/esm/services/common/httpError.js +0 -28
  251. package/dist/esm/services/common/httpError.js.map +0 -1
  252. package/dist/esm/services/common/index.js +0 -17
  253. package/dist/esm/services/common/index.js.map +0 -1
  254. package/dist/esm/services/common/sendFile.js +0 -27
  255. package/dist/esm/services/common/sendFile.js.map +0 -1
  256. package/dist/esm/services/frontend/frontendFs.js +0 -66
  257. package/dist/esm/services/frontend/frontendFs.js.map +0 -1
  258. package/dist/esm/services/frontend/index.js +0 -11
  259. package/dist/esm/services/frontend/index.js.map +0 -1
  260. package/dist/esm/services/html/htmlGenerator.js +0 -192
  261. package/dist/esm/services/html/htmlGenerator.js.map +0 -1
  262. package/dist/esm/services/html/index.js +0 -11
  263. package/dist/esm/services/html/index.js.map +0 -1
  264. package/dist/esm/services/http/apiClient.js +0 -94
  265. package/dist/esm/services/http/apiClient.js.map +0 -1
  266. package/dist/esm/services/http/http.js +0 -180
  267. package/dist/esm/services/http/http.js.map +0 -1
  268. package/dist/esm/services/http/index.js +0 -17
  269. package/dist/esm/services/http/index.js.map +0 -1
  270. package/dist/esm/services/http/responsesBuilder.js +0 -152
  271. package/dist/esm/services/http/responsesBuilder.js.map +0 -1
  272. package/dist/esm/services/index.js +0 -6
  273. package/dist/esm/services/index.js.map +0 -1
  274. package/dist/esm/services/utils/ensureBearerToken.js +0 -94
  275. package/dist/esm/services/utils/ensureBearerToken.js.map +0 -1
  276. package/dist/esm/services/utils/index.js +0 -11
  277. package/dist/esm/services/utils/index.js.map +0 -1
  278. package/dist/esm/types/events.js +0 -1
  279. package/dist/esm/types/events.js.map +0 -1
  280. package/dist/esm/types/express.js +0 -1
  281. package/dist/esm/types/express.js.map +0 -1
  282. package/dist/esm/types/http.js +0 -1
  283. package/dist/esm/types/http.js.map +0 -1
  284. package/dist/esm/types/index.js +0 -7
  285. package/dist/esm/types/index.js.map +0 -1
  286. package/dist/esm/types/options.js +0 -1
  287. package/dist/esm/types/options.js.map +0 -1
  288. package/dist/esm/types/utils.js +0 -1
  289. package/dist/esm/types/utils.js.map +0 -1
  290. package/dist/esm/types/wootils.js +0 -1
  291. package/dist/esm/types/wootils.js.map +0 -1
  292. package/dist/esm/utils/fns/index.js +0 -5
  293. package/dist/esm/utils/fns/index.js.map +0 -1
  294. package/dist/esm/utils/fns/others.js +0 -6
  295. package/dist/esm/utils/fns/others.js.map +0 -1
  296. package/dist/esm/utils/fns/routes.js +0 -25
  297. package/dist/esm/utils/fns/routes.js.map +0 -1
  298. package/dist/esm/utils/fns/statuses.js +0 -6
  299. package/dist/esm/utils/fns/statuses.js.map +0 -1
  300. package/dist/esm/utils/fns/text.js +0 -6
  301. package/dist/esm/utils/fns/text.js.map +0 -1
  302. package/dist/esm/utils/index.js +0 -3
  303. package/dist/esm/utils/index.js.map +0 -1
  304. package/dist/esm/utils/wrappers.js +0 -41
  305. package/dist/esm/utils/wrappers.js.map +0 -1
  306. package/dist/index-Bwf7JHu9.d.mts +0 -1287
  307. package/dist/index.d.mts +0 -47
  308. package/dist/middlewares/common/errorHandler.d.mts +0 -132
  309. package/dist/middlewares/common/forceHTTPS.d.mts +0 -69
  310. package/dist/middlewares/common/hsts.d.mts +0 -110
  311. package/dist/middlewares/common/index.d.mts +0 -22
  312. package/dist/middlewares/html/fastHTML.d.mts +0 -180
  313. package/dist/middlewares/html/index.d.mts +0 -21
  314. package/dist/middlewares/html/showHTML.d.mts +0 -127
  315. package/dist/middlewares/index.d.mts +0 -30
  316. package/dist/middlewares/utils/index.d.mts +0 -20
  317. package/dist/middlewares/utils/versionValidator.d.mts +0 -215
  318. package/dist/services/common/appError.d.mts +0 -139
  319. package/dist/services/common/httpError.d.mts +0 -80
  320. package/dist/services/common/index.d.mts +0 -47
  321. package/dist/services/common/sendFile.d.mts +0 -102
  322. package/dist/services/frontend/frontendFs.d.mts +0 -96
  323. package/dist/services/frontend/index.d.mts +0 -40
  324. package/dist/services/html/htmlGenerator.d.mts +0 -237
  325. package/dist/services/html/index.d.mts +0 -43
  326. package/dist/services/http/apiClient.d.mts +0 -170
  327. package/dist/services/http/http.d.mts +0 -182
  328. package/dist/services/http/index.d.mts +0 -51
  329. package/dist/services/http/responsesBuilder.d.mts +0 -179
  330. package/dist/services/index.d.mts +0 -33
  331. package/dist/services/utils/ensureBearerToken.d.mts +0 -158
  332. package/dist/services/utils/index.d.mts +0 -44
  333. package/dist/types/events.d.mts +0 -14
  334. package/dist/types/express.d.mts +0 -10
  335. package/dist/types/http.d.mts +0 -82
  336. package/dist/types/index.d.mts +0 -14
  337. package/dist/types/options.d.mts +0 -14
  338. package/dist/types/utils.d.mts +0 -48
  339. package/dist/types/wootils.d.mts +0 -4
  340. package/dist/utils/fns/index.d.mts +0 -5
  341. package/dist/utils/fns/others.d.mts +0 -17
  342. package/dist/utils/fns/routes.d.mts +0 -39
  343. package/dist/utils/fns/statuses.d.mts +0 -45
  344. package/dist/utils/fns/text.d.mts +0 -9
  345. package/dist/utils/index.d.mts +0 -19
  346. package/dist/utils/wrappers.d.mts +0 -14
@@ -1,127 +0,0 @@
1
- import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex, R as MiddlewareConnectFn } from '../../index-Bwf7JHu9.mjs';
3
- import { AsyncExpressMiddleware } from '../../types/express.mjs';
4
- import { SendFile } from '../../services/common/sendFile.mjs';
5
- import { HTMLGenerator } from '../../services/html/htmlGenerator.mjs';
6
- import { Response, NextFunction } from 'express';
7
- import '../../types/http.mjs';
8
- import 'https';
9
- import 'http';
10
- import 'spdy';
11
- import 'node-fetch';
12
- import '../../types/utils.mjs';
13
- import '@homer0/path-utils';
14
- import '@homer0/simple-logger';
15
- import '@homer0/simple-config';
16
- import '@homer0/events-hub';
17
- import '../../services/frontend/frontendFs.mjs';
18
- import 'fs/promises';
19
- import '@homer0/deferred';
20
-
21
- /**
22
- * The options to customize the behavior of the middleware.
23
- *
24
- * @group Middlewares/ShowHTML
25
- */
26
- type ShowHTMLOptions = {
27
- /**
28
- * The name of the file the middleware will serve. If the {@link HTMLGenerator} service
29
- * is available, it will be overriden by the service.
30
- *
31
- * @default 'index.html'
32
- */
33
- file: string;
34
- };
35
- /**
36
- * The options to construct a {@link ShowHTML}.
37
- *
38
- * @group Middlewares/ShowHTML
39
- */
40
- type ShowHTMLConstructorOptions = Partial<ShowHTMLOptions> & {
41
- /**
42
- * A dictionary with the dependencies to inject.
43
- */
44
- inject: {
45
- sendFile: SendFile;
46
- /**
47
- * A function to get a possible {@link HTMLGenerator}. This is injected as a "getter"
48
- * to not interrupt the DIC "lifecycle": middlewares are initialized right when the
49
- * app starts, and injecting a reference would force the service to be initialized
50
- * too, even if a request is not being made.
51
- */
52
- getHTMLGenerator?: () => HTMLGenerator | undefined;
53
- };
54
- };
55
- /**
56
- * The options for the middleware creator that will mount an instance of {@link ShowHTML}.
57
- *
58
- * @group Middlewares/ShowHTML
59
- */
60
- type ShowHTMLMiddlewareOptions = Partial<ShowHTMLOptions> & {
61
- /**
62
- * The name of an {@link HTMLGenerator} service already available in the application.
63
- *
64
- * @default 'htmlGenerator'
65
- */
66
- htmlGeneratorServiceName?: string;
67
- };
68
- /**
69
- * A very simple middleware service to send an HTML on a server response. The special
70
- * _'feature'_ of this service is that it can be hooked up to an {@link HTMLGenerator}
71
- * service and it will automatically server the file generated by it.
72
- *
73
- * @group Middleware Classes
74
- * @group Middlewares/ShowHTML
75
- * @prettierignore
76
- */
77
- declare class ShowHTML {
78
- /**
79
- * The service that serves a file.
80
- */
81
- protected readonly _sendFile: SendFile;
82
- /**
83
- * A function to get a possible {@link HTMLGenerator}. This is injected as a "getter"
84
- * to not interrupt the DIC "lifecycle": middlewares are initialized right when the
85
- * app starts, and injecting a reference would force the service to be initialized
86
- * too, even if a request is not being made.
87
- */
88
- protected readonly _getHTMLGenerator: () => HTMLGenerator | undefined;
89
- /**
90
- * The customization options for the middleware.
91
- */
92
- protected _options: ShowHTMLOptions;
93
- /**
94
- * Whether or not the file is ready to be served. In case the middleware uses an
95
- * {@link HTMLGenerator} service, the file needs to be generated before being available,
96
- * and that's why this flag exists.
97
- */
98
- protected _fileReady: boolean;
99
- /**
100
- * @param options The options to construct the class.
101
- */
102
- constructor({ inject, ...options }: ShowHTMLConstructorOptions);
103
- /**
104
- * Generates the middleware that serves the HTML file.
105
- */
106
- getMiddleware(): AsyncExpressMiddleware;
107
- /**
108
- * The customization options.
109
- */
110
- get options(): Readonly<ShowHTMLOptions>;
111
- /**
112
- * Serves the HTML file to the response.
113
- *
114
- * @param res The response object generated by the application.
115
- * @param next The function to call the next middleware.
116
- */
117
- protected _sendResponse(res: Response, next: NextFunction): void;
118
- }
119
- /**
120
- * Creates the middleware that serves an HTML file in the response.
121
- *
122
- * @group Middlewares
123
- * @group Middlewares/ShowHTML
124
- */
125
- declare const showHTMLMiddleware: _homer0_jimple.ResourceCreator<"middleware", "connect", (options?: ShowHTMLMiddlewareOptions) => <ContainerType extends Jimpex = Jimpex>(app: ContainerType) => AsyncExpressMiddleware, MiddlewareConnectFn>;
126
-
127
- export { ShowHTML, type ShowHTMLConstructorOptions, type ShowHTMLMiddlewareOptions, type ShowHTMLOptions, showHTMLMiddleware };
@@ -1,30 +0,0 @@
1
- export { ErrorHandler, ErrorHandlerConstructorOptions, ErrorHandlerOptions, ErrorHandlerPartialOptions, ErrorHandlerResponseOptions, errorHandlerMiddleware } from './common/errorHandler.mjs';
2
- export { ForceHTTPS, ForceHTTPSOptions, ForceHTTPSPartialOptions, forceHTTPSMiddleware } from './common/forceHTTPS.mjs';
3
- export { HSTS, HSTSMiddlewareOptions, HSTSMiddlewarePartialOptions, HSTSMiddlewareSettings, hstsMiddleware } from './common/hsts.mjs';
4
- export { FastHTML, FastHTMLConstructorOptions, FastHTMLMiddlewareOptions, FastHTMLOptions, fastHTMLMiddleware } from './html/fastHTML.mjs';
5
- export { ShowHTML, ShowHTMLConstructorOptions, ShowHTMLMiddlewareOptions, ShowHTMLOptions, showHTMLMiddleware } from './html/showHTML.mjs';
6
- export { VersionValidator, VersionValidatorConstructorOptions, VersionValidatorLatestOptions, VersionValidatorMiddlewareOptions, VersionValidatorOptions, VersionValidatorPartialOptions, VersionValidatorPopupOptions, versionValidatorMiddleware } from './utils/versionValidator.mjs';
7
- import '@homer0/jimple';
8
- import '../utils/fns/statuses.mjs';
9
- import 'statuses';
10
- import '../index-Bwf7JHu9.mjs';
11
- import '../types/express.mjs';
12
- import 'express';
13
- import '../types/http.mjs';
14
- import 'https';
15
- import 'http';
16
- import 'spdy';
17
- import 'node-fetch';
18
- import '../types/utils.mjs';
19
- import '@homer0/path-utils';
20
- import '@homer0/simple-logger';
21
- import '@homer0/simple-config';
22
- import '@homer0/events-hub';
23
- import '../services/common/httpError.mjs';
24
- import '../services/common/appError.mjs';
25
- import '../services/http/responsesBuilder.mjs';
26
- import '../services/common/sendFile.mjs';
27
- import '../services/html/htmlGenerator.mjs';
28
- import '../services/frontend/frontendFs.mjs';
29
- import 'fs/promises';
30
- import '@homer0/deferred';
@@ -1,20 +0,0 @@
1
- export { VersionValidator, VersionValidatorConstructorOptions, VersionValidatorLatestOptions, VersionValidatorMiddlewareOptions, VersionValidatorOptions, VersionValidatorPartialOptions, VersionValidatorPopupOptions, versionValidatorMiddleware } from './versionValidator.mjs';
2
- import '@homer0/jimple';
3
- import '../../utils/fns/statuses.mjs';
4
- import 'statuses';
5
- import '../../index-Bwf7JHu9.mjs';
6
- import '../../types/express.mjs';
7
- import 'express';
8
- import '../../types/http.mjs';
9
- import 'https';
10
- import 'http';
11
- import 'spdy';
12
- import 'node-fetch';
13
- import '../../types/utils.mjs';
14
- import '@homer0/path-utils';
15
- import '@homer0/simple-logger';
16
- import '@homer0/simple-config';
17
- import '@homer0/events-hub';
18
- import '../../services/common/httpError.mjs';
19
- import '../../services/common/appError.mjs';
20
- import '../../services/http/responsesBuilder.mjs';
@@ -1,215 +0,0 @@
1
- import * as _homer0_jimple from '@homer0/jimple';
2
- import { Statuses } from '../../utils/fns/statuses.mjs';
3
- import { J as Jimpex, R as MiddlewareConnectFn } from '../../index-Bwf7JHu9.mjs';
4
- import { ExpressMiddleware } from '../../types/express.mjs';
5
- import { DeepPartial } from '../../types/utils.mjs';
6
- import { HTTPErrorClass } from '../../services/common/httpError.mjs';
7
- import { ResponsesBuilder } from '../../services/http/responsesBuilder.mjs';
8
- import { Request } from 'express';
9
- import 'statuses';
10
- import '../../types/http.mjs';
11
- import 'https';
12
- import 'http';
13
- import 'spdy';
14
- import 'node-fetch';
15
- import '@homer0/path-utils';
16
- import '@homer0/simple-logger';
17
- import '@homer0/simple-config';
18
- import '@homer0/events-hub';
19
- import '../../services/common/appError.mjs';
20
-
21
- /**
22
- * The options for how the middleware should behave if the requested version is `latest`.
23
- *
24
- * @group Middlewares/VersionValidator
25
- */
26
- type VersionValidatorLatestOptions = {
27
- /**
28
- * Whether or not the middleware should validate the _"latest version"_.
29
- *
30
- * @default true
31
- */
32
- allow: boolean;
33
- /**
34
- * The name of the _"latest version"_. Basically, `req.params.version` must match with
35
- * this property in order to be consider "latest".
36
- *
37
- * @default 'latest'
38
- */
39
- name: string;
40
- };
41
- /**
42
- * The options for how to detect if the request comes from a popup and how to compose the
43
- * post message the middleware will use to respond.
44
- *
45
- * @group Middlewares/VersionValidator
46
- */
47
- type VersionValidatorPopupOptions = {
48
- /**
49
- * The name of the query string variable the middleware will check in order to indentify
50
- * whether the request comes from a popup or not. The variable must have `'true'` as its
51
- * value.
52
- *
53
- * @default 'popup'
54
- */
55
- variable: string;
56
- /**
57
- * The title of the page that will be generated to respond in case the versions don't
58
- * match.
59
- *
60
- * @default 'Conflict'
61
- */
62
- title: string;
63
- /**
64
- * The contents of the post message the generated page will send if the versions don't
65
- * match.
66
- *
67
- * @default 'version:conflict'
68
- */
69
- message: string;
70
- };
71
- /**
72
- * The options used to customize a {@link VersionValidator} instance.
73
- *
74
- * @group Middlewares/VersionValidator
75
- */
76
- type VersionValidatorOptions = {
77
- /**
78
- * The version used to validate the requests.
79
- */
80
- version: string;
81
- /**
82
- * The options for how the middleware should behave if the requested version is
83
- * `latest`.
84
- */
85
- latest: VersionValidatorLatestOptions;
86
- /**
87
- * The options for how to detect if the request comes from a popup and how to compose
88
- * the post message the middleware will use to respond.
89
- */
90
- popup: VersionValidatorPopupOptions;
91
- /**
92
- * The error message to show when the version is invalid.
93
- *
94
- * @default "The application version doesn't match"
95
- * @prettierignore
96
- */
97
- error: string;
98
- };
99
- /**
100
- * A partial version of the {@link VersionValidatorOptions}, to be used in the constructor
101
- * and the middleware creator. The reason it omits `version` it's because for the
102
- * constructor it's required, but for the middleware creator it's not.
103
- *
104
- * @group Middlewares/VersionValidator
105
- */
106
- type VersionValidatorPartialOptions = DeepPartial<Omit<VersionValidatorOptions, 'version'>>;
107
- /**
108
- * The options to construct a {@link VersionValidator}.
109
- *
110
- * @group Middlewares/VersionValidator
111
- */
112
- type VersionValidatorConstructorOptions = VersionValidatorPartialOptions & {
113
- /**
114
- * The version used to validate the requests.
115
- */
116
- version: string;
117
- /**
118
- * A dictionary with the dependencies to inject.
119
- */
120
- inject: {
121
- HTTPError: HTTPErrorClass;
122
- responsesBuilder: ResponsesBuilder;
123
- statuses: Statuses;
124
- };
125
- };
126
- /**
127
- * The options for the middleware creator that will mount an instance of
128
- * {@link VersionValidator}.
129
- *
130
- * @group Middlewares/VersionValidator
131
- */
132
- type VersionValidatorMiddlewareOptions = VersionValidatorPartialOptions & {
133
- /**
134
- * The version used to validate the requests. This is optional in here because if it's
135
- * not specified, it will be obtained from the configuration service.
136
- */
137
- version?: string;
138
- };
139
- /**
140
- * This is the handler for the middleware/controller that validates the application
141
- * version.
142
- * This is useful in cases where you want to restrict the access to specific versions; for
143
- * example: you have a frontend which needs to be aligned with the "current" version of
144
- * the application, since the frontend won't realize a new version was released, the
145
- * validator can be used to let the frontend know.
146
- * Also, it can be configured to handle requests from popups, in which case, instead of
147
- * generating an error message, it will send a post message.
148
- *
149
- * @group Middleware Classes
150
- * @group Middlewares/VersionValidator
151
- * @prettierignore
152
- */
153
- declare class VersionValidator {
154
- /**
155
- * To generate the errors in case the validation fails.
156
- */
157
- protected readonly _HTTPError: HTTPErrorClass;
158
- /**
159
- * To generate responses for popups.
160
- */
161
- protected readonly _responsesBuilder: ResponsesBuilder;
162
- /**
163
- * The uility service to get HTTP status codes.
164
- */
165
- protected readonly _statuses: Statuses;
166
- /**
167
- * The customization options.
168
- */
169
- protected readonly _options: VersionValidatorOptions;
170
- /**
171
- * @param options The options to construct the class.
172
- * @throws If no `version` is specified in the options.
173
- */
174
- constructor({ inject, version, ...options }: VersionValidatorConstructorOptions);
175
- /**
176
- * Generates the middleware that validates the version.
177
- */
178
- getMiddleware(): ExpressMiddleware;
179
- /**
180
- * The customization options.
181
- */
182
- get options(): Readonly<VersionValidatorOptions>;
183
- /**
184
- * Helper method that checks if the incoming request is from a popup. It will look for
185
- * the query string variable defined in the constructor options.
186
- *
187
- * @param req The request object sent by the application.
188
- */
189
- protected _isPopup(req: Request): boolean;
190
- /**
191
- * Helper method that checks if the "latest version" is enabled and if the given version
192
- * is "the latest" (comparing it with the option name).
193
- *
194
- * @param version The version received in the request.
195
- */
196
- protected _isTheAllowedLatest(version: string): boolean;
197
- }
198
- /**
199
- * A middleware that will validate a `version` request parameter against the application
200
- * version, and generate an error if they don't match.
201
- * This is a "middleware/controller" because the wrappers for both are the same, the
202
- * difference is that, for controllers, Jimpex sends a second parameter with the route
203
- * where they are mounted.
204
- * By validating the route parameter, the function can know whether the implementation is
205
- * going to use the middleware by itself or as a route middleware.
206
- * If used as middleware, it will just return the result of
207
- * {@link VersionValidator.getMiddleware}; but if used as controller, it will mount it on
208
- * `[route]/:version/*`.
209
- *
210
- * @group Middlewares
211
- * @group Middlewares/VersionValidator
212
- */
213
- declare const versionValidatorMiddleware: _homer0_jimple.ResourceCreator<"middleware", "connect", (options?: VersionValidatorMiddlewareOptions) => <ContainerType extends Jimpex = Jimpex>(app: ContainerType, route: string | undefined) => ExpressMiddleware, MiddlewareConnectFn>;
214
-
215
- export { VersionValidator, type VersionValidatorConstructorOptions, type VersionValidatorLatestOptions, type VersionValidatorMiddlewareOptions, type VersionValidatorOptions, type VersionValidatorPartialOptions, type VersionValidatorPopupOptions, versionValidatorMiddleware };
@@ -1,139 +0,0 @@
1
- import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
3
- import { Statuses } from '../../utils/fns/statuses.mjs';
4
- import '../../types/express.mjs';
5
- import 'express';
6
- import '../../types/http.mjs';
7
- import 'https';
8
- import 'http';
9
- import 'spdy';
10
- import 'node-fetch';
11
- import '../../types/utils.mjs';
12
- import '@homer0/path-utils';
13
- import '@homer0/simple-logger';
14
- import '@homer0/simple-config';
15
- import '@homer0/events-hub';
16
- import 'statuses';
17
-
18
- /**
19
- * A dictionary with some context information that can be provided to {@link AppError}.
20
- *
21
- * @group Services/AppError
22
- */
23
- type AppErrorContext = {
24
- /**
25
- * Extra information that the error handler can pick and include the response.
26
- */
27
- response?: unknown;
28
- /**
29
- * A status code or name for the error handler to set in the response.
30
- */
31
- status?: string | number;
32
- } & Record<string, unknown>;
33
- /**
34
- * A simple subclass of `Error` but with support for context information.
35
- *
36
- * @group Services
37
- * @group Services/AppError
38
- */
39
- declare class AppError extends Error {
40
- /**
41
- * The date of when the error was generated.
42
- */
43
- readonly _date: Date;
44
- /**
45
- * The context information that can be provided to the error, and picked by the error
46
- * handler.
47
- */
48
- readonly _context: AppErrorContext;
49
- /**
50
- * The service that generates HTTP status codes.
51
- */
52
- protected _statuses: Statuses;
53
- /**
54
- * @param message The message of the error.
55
- * @param context The context information, for the error handler.
56
- * @param statuses A reference to the service that generates HTTP status codes. This
57
- * is in case the implementation wants to use a special version from
58
- * the container; otherwise, it will use the `statuses` library
59
- * directly.
60
- */
61
- constructor(message: string, context?: AppErrorContext, statuses?: Statuses);
62
- /**
63
- * Gets an object that can be included in a response from the application. This method
64
- * is a helper for the `response` getter, as it allows for the assertion of the response
65
- * type.
66
- *
67
- * @template T The type of the response.
68
- */
69
- getResponse<T>(): T;
70
- /**
71
- * Information about the error that can be included in a response. This is set using the
72
- * `response` key in the `context` option.
73
- */
74
- get response(): unknown;
75
- /**
76
- * An HTTP status code related to the error. This is set using the `status` key on the
77
- * `context`.
78
- */
79
- get status(): number | undefined;
80
- /**
81
- * Context information related to the error.
82
- */
83
- get context(): unknown;
84
- /**
85
- * The date of when the error was generated.
86
- */
87
- get date(): Date;
88
- /**
89
- * Utility method that formats the context before saving it in the instance:
90
- * - If the context includes a `status` as a `string`, it will try to replace it with
91
- * its actual status code from the `statuses `service.
92
- *
93
- * @param context The original context sent to the constructor.
94
- */
95
- protected _parseContext(context: AppErrorContext): AppErrorContext;
96
- }
97
- /**
98
- * Shorthand for `new AppError()`.
99
- *
100
- * @param args The same parameters as the {@link AppError} constructor.
101
- * @returns A new instance of {@link AppError}.
102
- * @group Services
103
- * @group Services/AppError
104
- */
105
- declare const createAppError: (message: string, context?: AppErrorContext | undefined, statuses?: Statuses | undefined) => AppError;
106
- /**
107
- * The type of the function that generates a new instance of {@link AppError}.
108
- * This is exported to make it easy to type the dependency injection.
109
- *
110
- * @group Services/AppError
111
- */
112
- type CreateAppErrorFn = typeof createAppError;
113
- /**
114
- * THe type of the {@link AppError} class.
115
- * This is exported to make it easy to type the dependency injection.
116
- *
117
- * @group Services/AppError
118
- */
119
- type AppErrorClass = typeof AppError;
120
- /**
121
- * A service provider that will register both, {@link AppError} and
122
- * {@link createAppError}, on the container. `AppError` will be the key for class, and
123
- * `appError` will be for the generator function.
124
- *
125
- * @example
126
- *
127
- * // Register it on the container
128
- * container.register(appErrorProvider);
129
- * // Getting access to the class.
130
- * const AppError = container.get<AppErrorClass>('AppError');
131
- * // Getting access to the function.
132
- * const appError = container.get<CreateAppErrorFn>('appError');
133
- *
134
- * @group Providers
135
- * @group Services/AppError
136
- */
137
- declare const appErrorProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
138
-
139
- export { AppError, type AppErrorClass, type AppErrorContext, type CreateAppErrorFn, appErrorProvider, createAppError };
@@ -1,80 +0,0 @@
1
- import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
3
- import { Statuses } from '../../utils/fns/statuses.mjs';
4
- import { AppError, AppErrorContext } from './appError.mjs';
5
- import '../../types/express.mjs';
6
- import 'express';
7
- import '../../types/http.mjs';
8
- import 'https';
9
- import 'http';
10
- import 'spdy';
11
- import 'node-fetch';
12
- import '../../types/utils.mjs';
13
- import '@homer0/path-utils';
14
- import '@homer0/simple-logger';
15
- import '@homer0/simple-config';
16
- import '@homer0/events-hub';
17
- import 'statuses';
18
-
19
- /**
20
- * A type of error to be used on HTTP requests. This is the most common type of error used
21
- * by Jimpex.
22
- *
23
- * @group Services
24
- * @group Services/HTTPError
25
- */
26
- declare class HTTPError extends AppError {
27
- /**
28
- * @param message The error message.
29
- * @param status The HTTP status code.
30
- * @param context Context information related to the error.
31
- * @param statuses A reference to the service that generates HTTP status codes. This
32
- * is in case the implementation wants to use a special version from
33
- * the container; otherwise, it will use the `statuses` library
34
- * directly.
35
- */
36
- constructor(message: string, status?: number | string, context?: AppErrorContext, statuses?: Statuses);
37
- }
38
- /**
39
- * Shorthand for `new HTTPError()`.
40
- *
41
- * @param args The same parameters as the {@link HTTPError} constructor.
42
- * @returns A new instance of {@link HTTPError}.
43
- * @group Services
44
- * @group Services/HTTPError
45
- */
46
- declare const createHTTPError: (message: string, status?: string | number | undefined, context?: AppErrorContext | undefined, statuses?: Statuses | undefined) => HTTPError;
47
- /**
48
- * The type of the function that generates a new instance of {@link HTTPError}.
49
- * This is exported to make it easy to type the dependency injection.
50
- *
51
- * @group Services/HTTPError
52
- */
53
- type CreateHTTPErrorFn = typeof createHTTPError;
54
- /**
55
- * THe type of the {@link HTTPError} class.
56
- * This is exported to make it easy to type the dependency injection.
57
- *
58
- * @group Services/HTTPError
59
- */
60
- type HTTPErrorClass = typeof HTTPError;
61
- /**
62
- * A service provider that will register both the {@link HTTPError} and a generator
63
- * function on the container. `HTTPError` will be the key for class, and `httpError` will
64
- * be for the generator function.
65
- *
66
- * @example
67
- *
68
- * // Register it on the container
69
- * container.register(httpErrorProvider);
70
- * // Getting access to the class.
71
- * const HTTPError = container.get<HTTPErrorClass>('HTTPError');
72
- * // Getting access to the function.
73
- * const httpError = container.get<CreateHTTPErrorFn>('httpError');
74
- *
75
- * @group Providers
76
- * @group Services/HTTPError
77
- */
78
- declare const httpErrorProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
79
-
80
- export { type CreateHTTPErrorFn, HTTPError, type HTTPErrorClass, createHTTPError, httpErrorProvider };
@@ -1,47 +0,0 @@
1
- import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
3
- export { AppError, AppErrorClass, AppErrorContext, CreateAppErrorFn, appErrorProvider, createAppError } from './appError.mjs';
4
- export { CreateHTTPErrorFn, HTTPError, HTTPErrorClass, createHTTPError, httpErrorProvider } from './httpError.mjs';
5
- export { SendFile, SendFileGeneratorOptions, SendFileOptions, sendFile, sendFileProvider } from './sendFile.mjs';
6
- import '../../types/express.mjs';
7
- import 'express';
8
- import '../../types/http.mjs';
9
- import 'https';
10
- import 'http';
11
- import 'spdy';
12
- import 'node-fetch';
13
- import '../../types/utils.mjs';
14
- import '@homer0/path-utils';
15
- import '@homer0/simple-logger';
16
- import '@homer0/simple-config';
17
- import '@homer0/events-hub';
18
- import '../../utils/fns/statuses.mjs';
19
- import 'statuses';
20
-
21
- /**
22
- * Registers all the common services on the container.
23
- *
24
- * - {@link AppError | appError}
25
- * - {@link HTTPError | httpError}
26
- * - {@link SendFile | sendFile}
27
- *
28
- * @example
29
- *
30
- * // Register the collection on the container
31
- * container.register(commonServicesProvider);
32
- * // Getting access to one the services instance
33
- * const sendFile = container.get<SendFile>('sendFile');
34
- *
35
- * @group Providers
36
- */
37
- declare const commonServicesProvider: {
38
- appErrorProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
39
- httpErrorProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
40
- sendFileProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
41
- } & Record<string, _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>> & {
42
- provider: true;
43
- } & {
44
- register: _homer0_jimple.ProviderRegisterFn<Jimpex>;
45
- } & Record<string, unknown>;
46
-
47
- export { commonServicesProvider };