jimpex 10.0.2 → 11.0.1

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 +36 -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,31 +1,6 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var httpError_exports = {};
20
- __export(httpError_exports, {
21
- HTTPError: () => HTTPError,
22
- createHTTPError: () => createHTTPError,
23
- httpErrorProvider: () => httpErrorProvider
24
- });
25
- module.exports = __toCommonJS(httpError_exports);
26
- var import_utils = require("../../utils");
27
- var import_appError = require("./appError");
28
- class HTTPError extends import_appError.AppError {
1
+ import { provider, statuses as statusesFn } from "../../utils/index.js";
2
+ import { AppError } from "./appError.js";
3
+ class HTTPError extends AppError {
29
4
  /**
30
5
  * @param message The error message.
31
6
  * @param status The HTTP status code.
@@ -35,19 +10,18 @@ class HTTPError extends import_appError.AppError {
35
10
  * the container; otherwise, it will use the `statuses` library
36
11
  * directly.
37
12
  */
38
- constructor(message, status = (0, import_utils.statuses)("ok"), context = {}, statuses = import_utils.statuses) {
13
+ constructor(message, status = statusesFn("ok"), context = {}, statuses = statusesFn) {
39
14
  super(message, { ...context, status }, statuses);
40
15
  }
41
16
  }
42
17
  const createHTTPError = (...args) => new HTTPError(...args);
43
- const httpErrorProvider = (0, import_utils.provider)((app) => {
18
+ const httpErrorProvider = provider((app) => {
44
19
  app.set("HTTPError", () => HTTPError);
45
20
  app.set("httpError", () => createHTTPError);
46
21
  });
47
- // Annotate the CommonJS export names for ESM import in node:
48
- 0 && (module.exports = {
22
+ export {
49
23
  HTTPError,
50
24
  createHTTPError,
51
25
  httpErrorProvider
52
- });
26
+ };
53
27
  //# sourceMappingURL=httpError.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/services/common/httpError.ts"],"sourcesContent":["import { provider, statuses as statusesFn, type Statuses } from '../../utils';\nimport { AppError, type AppErrorContext } from './appError';\n/**\n * A type of error to be used on HTTP requests. This is the most common type of error used\n * by Jimpex.\n *\n * @group Services\n * @group Services/HTTPError\n */\nexport class HTTPError extends AppError {\n /**\n * @param message The error message.\n * @param status The HTTP status code.\n * @param context Context information related to the error.\n * @param statuses A reference to the service that generates HTTP status codes. This\n * is in case the implementation wants to use a special version from\n * the container; otherwise, it will use the `statuses` library\n * directly.\n */\n constructor(\n message: string,\n status: number | string = statusesFn('ok'),\n context: AppErrorContext = {},\n statuses: Statuses = statusesFn,\n ) {\n super(message, { ...context, status }, statuses);\n }\n}\n/**\n * Shorthand for `new HTTPError()`.\n *\n * @param args The same parameters as the {@link HTTPError} constructor.\n * @returns A new instance of {@link HTTPError}.\n * @group Services\n * @group Services/HTTPError\n */\nexport const createHTTPError = (\n ...args: ConstructorParameters<typeof HTTPError>\n): HTTPError => new HTTPError(...args);\n/**\n * The type of the function that generates a new instance of {@link HTTPError}.\n * This is exported to make it easy to type the dependency injection.\n *\n * @group Services/HTTPError\n */\nexport type CreateHTTPErrorFn = typeof createHTTPError;\n/**\n * THe type of the {@link HTTPError} class.\n * This is exported to make it easy to type the dependency injection.\n *\n * @group Services/HTTPError\n */\nexport type HTTPErrorClass = typeof HTTPError;\n/**\n * A service provider that will register both the {@link HTTPError} and a generator\n * function on the container. `HTTPError` will be the key for class, and `httpError` will\n * be for the generator function.\n *\n * @example\n *\n * // Register it on the container\n * container.register(httpErrorProvider);\n * // Getting access to the class.\n * const HTTPError = container.get<HTTPErrorClass>('HTTPError');\n * // Getting access to the function.\n * const httpError = container.get<CreateHTTPErrorFn>('httpError');\n *\n * @group Providers\n * @group Services/HTTPError\n */\nexport const httpErrorProvider = provider((app) => {\n app.set('HTTPError', () => HTTPError);\n app.set('httpError', () => createHTTPError);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgE;AAChE,sBAA+C;AAQxC,MAAM,kBAAkB,yBAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUtC,YACE,SACA,aAA0B,aAAAA,UAAW,IAAI,GACzC,UAA2B,CAAC,GAC5B,WAAqB,aAAAA,UACrB;AACA,UAAM,SAAS,EAAE,GAAG,SAAS,OAAO,GAAG,QAAQ;AAAA,EACjD;AACF;AASO,MAAM,kBAAkB,IAC1B,SACW,IAAI,UAAU,GAAG,IAAI;AAgC9B,MAAM,wBAAoB,uBAAS,CAAC,QAAQ;AACjD,MAAI,IAAI,aAAa,MAAM,SAAS;AACpC,MAAI,IAAI,aAAa,MAAM,eAAe;AAC5C,CAAC;","names":["statusesFn"]}
1
+ {"version":3,"sources":["../../../src/services/common/httpError.ts"],"sourcesContent":["import { provider, statuses as statusesFn, type Statuses } from '../../utils/index.js';\nimport { AppError, type AppErrorContext } from './appError.js';\n/**\n * A type of error to be used on HTTP requests. This is the most common type of error used\n * by Jimpex.\n *\n * @group Services\n * @group Services/HTTPError\n */\nexport class HTTPError extends AppError {\n /**\n * @param message The error message.\n * @param status The HTTP status code.\n * @param context Context information related to the error.\n * @param statuses A reference to the service that generates HTTP status codes. This\n * is in case the implementation wants to use a special version from\n * the container; otherwise, it will use the `statuses` library\n * directly.\n */\n constructor(\n message: string,\n status: number | string = statusesFn('ok'),\n context: AppErrorContext = {},\n statuses: Statuses = statusesFn,\n ) {\n super(message, { ...context, status }, statuses);\n }\n}\n/**\n * Shorthand for `new HTTPError()`.\n *\n * @param args The same parameters as the {@link HTTPError} constructor.\n * @returns A new instance of {@link HTTPError}.\n * @group Services\n * @group Services/HTTPError\n */\nexport const createHTTPError = (\n ...args: ConstructorParameters<typeof HTTPError>\n): HTTPError => new HTTPError(...args);\n/**\n * The type of the function that generates a new instance of {@link HTTPError}.\n * This is exported to make it easy to type the dependency injection.\n *\n * @group Services/HTTPError\n */\nexport type CreateHTTPErrorFn = typeof createHTTPError;\n/**\n * THe type of the {@link HTTPError} class.\n * This is exported to make it easy to type the dependency injection.\n *\n * @group Services/HTTPError\n */\nexport type HTTPErrorClass = typeof HTTPError;\n/**\n * A service provider that will register both the {@link HTTPError} and a generator\n * function on the container. `HTTPError` will be the key for class, and `httpError` will\n * be for the generator function.\n *\n * @example\n *\n * // Register it on the container\n * container.register(httpErrorProvider);\n * // Getting access to the class.\n * const HTTPError = container.get<HTTPErrorClass>('HTTPError');\n * // Getting access to the function.\n * const httpError = container.get<CreateHTTPErrorFn>('httpError');\n *\n * @group Providers\n * @group Services/HTTPError\n */\nexport const httpErrorProvider = provider((app) => {\n app.set('HTTPError', () => HTTPError);\n app.set('httpError', () => createHTTPError);\n});\n"],"mappings":"AAAA,SAAS,UAAU,YAAY,kBAAiC;AAChE,SAAS,gBAAsC;AAQxC,MAAM,kBAAkB,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUtC,YACE,SACA,SAA0B,WAAW,IAAI,GACzC,UAA2B,CAAC,GAC5B,WAAqB,YACrB;AACA,UAAM,SAAS,EAAE,GAAG,SAAS,OAAO,GAAG,QAAQ;AAAA,EACjD;AACF;AASO,MAAM,kBAAkB,IAC1B,SACW,IAAI,UAAU,GAAG,IAAI;AAgC9B,MAAM,oBAAoB,SAAS,CAAC,QAAQ;AACjD,MAAI,IAAI,aAAa,MAAM,SAAS;AACpC,MAAI,IAAI,aAAa,MAAM,eAAe;AAC5C,CAAC;","names":[]}
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-C6I3NCC-.js';
2
+ import { J as Jimpex } from '../../index-BlSpNHox.js';
3
3
  export { AppError, AppErrorClass, AppErrorContext, CreateAppErrorFn, appErrorProvider, createAppError } from './appError.js';
4
4
  export { CreateHTTPErrorFn, HTTPError, HTTPErrorClass, createHTTPError, httpErrorProvider } from './httpError.js';
5
5
  export { SendFile, SendFileGeneratorOptions, SendFileOptions, sendFile, sendFileProvider } from './sendFile.js';
@@ -1,44 +1,16 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var common_exports = {};
21
- __export(common_exports, {
22
- commonServicesProvider: () => commonServicesProvider
23
- });
24
- module.exports = __toCommonJS(common_exports);
25
- var import_utils = require("../../utils");
26
- var import_appError = require("./appError");
27
- var import_httpError = require("./httpError");
28
- var import_sendFile = require("./sendFile");
29
- __reExport(common_exports, require("./appError"), module.exports);
30
- __reExport(common_exports, require("./httpError"), module.exports);
31
- __reExport(common_exports, require("./sendFile"), module.exports);
32
- const commonServicesProvider = (0, import_utils.providers)({
33
- appErrorProvider: import_appError.appErrorProvider,
34
- httpErrorProvider: import_httpError.httpErrorProvider,
35
- sendFileProvider: import_sendFile.sendFileProvider
36
- });
37
- // Annotate the CommonJS export names for ESM import in node:
38
- 0 && (module.exports = {
39
- commonServicesProvider,
40
- ...require("./appError"),
41
- ...require("./httpError"),
42
- ...require("./sendFile")
1
+ import { providers } from "../../utils/index.js";
2
+ import { appErrorProvider } from "./appError.js";
3
+ import { httpErrorProvider } from "./httpError.js";
4
+ import { sendFileProvider } from "./sendFile.js";
5
+ const commonServicesProvider = providers({
6
+ appErrorProvider,
7
+ httpErrorProvider,
8
+ sendFileProvider
43
9
  });
10
+ export * from "./appError.js";
11
+ export * from "./httpError.js";
12
+ export * from "./sendFile.js";
13
+ export {
14
+ commonServicesProvider
15
+ };
44
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/services/common/index.ts"],"sourcesContent":["import { providers } from '../../utils';\nimport { appErrorProvider } from './appError';\nimport { httpErrorProvider } from './httpError';\nimport { sendFileProvider } from './sendFile';\n/**\n * Registers all the common services on the container.\n *\n * - {@link AppError | appError}\n * - {@link HTTPError | httpError}\n * - {@link SendFile | sendFile}\n *\n * @example\n *\n * // Register the collection on the container\n * container.register(commonServicesProvider);\n * // Getting access to one the services instance\n * const sendFile = container.get<SendFile>('sendFile');\n *\n * @group Providers\n */\nexport const commonServicesProvider = providers({\n appErrorProvider,\n httpErrorProvider,\n sendFileProvider,\n});\n\nexport * from './appError';\nexport * from './httpError';\nexport * from './sendFile';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;AAC1B,sBAAiC;AACjC,uBAAkC;AAClC,sBAAiC;AAuBjC,2BAAc,uBA1Bd;AA2BA,2BAAc,wBA3Bd;AA4BA,2BAAc,uBA5Bd;AAoBO,MAAM,6BAAyB,wBAAU;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AACF,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../../src/services/common/index.ts"],"sourcesContent":["import { providers } from '../../utils/index.js';\nimport { appErrorProvider } from './appError.js';\nimport { httpErrorProvider } from './httpError.js';\nimport { sendFileProvider } from './sendFile.js';\n/**\n * Registers all the common services on the container.\n *\n * - {@link AppError | appError}\n * - {@link HTTPError | httpError}\n * - {@link SendFile | sendFile}\n *\n * @example\n *\n * // Register the collection on the container\n * container.register(commonServicesProvider);\n * // Getting access to one the services instance\n * const sendFile = container.get<SendFile>('sendFile');\n *\n * @group Providers\n */\nexport const commonServicesProvider = providers({\n appErrorProvider,\n httpErrorProvider,\n sendFileProvider,\n});\n\nexport * from './appError.js';\nexport * from './httpError.js';\nexport * from './sendFile.js';\n"],"mappings":"AAAA,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AAiB1B,MAAM,yBAAyB,UAAU;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-C6I3NCC-.js';
2
+ import { J as Jimpex } from '../../index-BlSpNHox.js';
3
3
  import { Response, NextFunction } from 'express';
4
4
  import { PathUtils } from '@homer0/path-utils';
5
5
  import '../../types/express.js';
@@ -1,28 +1,4 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var sendFile_exports = {};
20
- __export(sendFile_exports, {
21
- sendFile: () => sendFile,
22
- sendFileProvider: () => sendFileProvider
23
- });
24
- module.exports = __toCommonJS(sendFile_exports);
25
- var import_utils = require("../../utils");
1
+ import { provider } from "../../utils/index.js";
26
2
  const sendFile = ({ inject: { pathUtils } }) => ({ res, filepath, from = "app", next = () => {
27
3
  } }) => {
28
4
  res.sendFile(pathUtils.joinFrom(from, filepath), (error) => {
@@ -33,7 +9,7 @@ const sendFile = ({ inject: { pathUtils } }) => ({ res, filepath, from = "app",
33
9
  }
34
10
  });
35
11
  };
36
- const sendFileProvider = (0, import_utils.provider)((app) => {
12
+ const sendFileProvider = provider((app) => {
37
13
  app.set(
38
14
  "sendFile",
39
15
  () => sendFile({
@@ -43,9 +19,8 @@ const sendFileProvider = (0, import_utils.provider)((app) => {
43
19
  })
44
20
  );
45
21
  });
46
- // Annotate the CommonJS export names for ESM import in node:
47
- 0 && (module.exports = {
22
+ export {
48
23
  sendFile,
49
24
  sendFileProvider
50
- });
25
+ };
51
26
  //# sourceMappingURL=sendFile.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/services/common/sendFile.ts"],"sourcesContent":["import { provider } from '../../utils';\nimport type { Response, NextFunction, PathUtils } from '../../types';\n/**\n * The options to create a {@link SendFile} function.\n *\n * @group Services/SendFile\n */\nexport type SendFileGeneratorOptions = {\n /**\n * A dictionary with the dependencies to inject.\n */\n inject: {\n pathUtils: PathUtils;\n };\n};\n/**\n * The options for the function that actually serves a file.\n *\n * @group Services/SendFile\n */\nexport type SendFileOptions = {\n /**\n * The response object sent by the application. Necessary to write the file.\n */\n res: Response;\n /**\n * The path of the file to serve. Depending on the `from` option, it will be either\n * relative to the project root, or the application executable.\n */\n filepath: string;\n /**\n * The name of a location on the `pathUtils` service from where the `filepath` is\n * relative to. It can be `app` for the directory containing the application executable,\n * or `project` for the project root. It could also be any other location that the\n * implementation may have registered.\n *\n * @default 'app'\n */\n from?: string;\n /**\n * The function to move to the next middleware. It can be used to report an error in\n * case the file can't be served.\n *\n * @default {() => {}}\n */\n next?: NextFunction;\n};\n/**\n * The type of the function that serves a file.\n * This is exported to make it easy to type the dependency injection.\n *\n * @group Services/SendFile\n */\nexport type SendFile = (options: SendFileOptions) => void;\n/**\n * Generates a function to send files on the application response.\n *\n * @param options To inject the required dependencies.\n * @example\n *\n * <caption>Basic usage</caption>\n *\n * // Let's say this is inside an Express middleware.\n * // Get the function\n * const send = sendFile(pathUtils);\n * send({ res, filepath: 'some-file.html', next });\n * // If your app is on \"/app/index.js\", this will send \"/app/some-file.html\".\n *\n * @group Services\n * @group Services/SendFile\n */\nexport const sendFile =\n ({ inject: { pathUtils } }: SendFileGeneratorOptions): SendFile =>\n ({ res, filepath, from = 'app', next = () => {} }) => {\n res.sendFile(pathUtils.joinFrom(from, filepath), (error) => {\n if (error) {\n next(error);\n } else {\n res.end();\n }\n });\n };\n\n/**\n * The service provider that once registered on the container will set the result of\n * {@link sendFile} as the `sendFile` service.\n *\n * @example\n *\n * // Register it on the container\n * container.register(sendFileProvider);\n * // Getting access to the service instance\n * const sendFile = container.get<SendFile>('sendFile');\n *\n * @group Providers\n * @group Services/SendFile\n */\nexport const sendFileProvider = provider((app) => {\n app.set('sendFile', () =>\n sendFile({\n inject: {\n pathUtils: app.get('pathUtils'),\n },\n }),\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAyB;AAuElB,MAAM,WACX,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,MACzB,CAAC,EAAE,KAAK,UAAU,OAAO,OAAO,OAAO,MAAM;AAAC,EAAE,MAAM;AACpD,MAAI,SAAS,UAAU,SAAS,MAAM,QAAQ,GAAG,CAAC,UAAU;AAC1D,QAAI,OAAO;AACT,WAAK,KAAK;AAAA,IACZ,OAAO;AACL,UAAI,IAAI;AAAA,IACV;AAAA,EACF,CAAC;AACH;AAgBK,MAAM,uBAAmB,uBAAS,CAAC,QAAQ;AAChD,MAAI;AAAA,IAAI;AAAA,IAAY,MAClB,SAAS;AAAA,MACP,QAAQ;AAAA,QACN,WAAW,IAAI,IAAI,WAAW;AAAA,MAChC;AAAA,IACF,CAAC;AAAA,EACH;AACF,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../../src/services/common/sendFile.ts"],"sourcesContent":["import { provider } from '../../utils/index.js';\nimport type { Response, NextFunction, PathUtils } from '../../types/index.js';\n/**\n * The options to create a {@link SendFile} function.\n *\n * @group Services/SendFile\n */\nexport type SendFileGeneratorOptions = {\n /**\n * A dictionary with the dependencies to inject.\n */\n inject: {\n pathUtils: PathUtils;\n };\n};\n/**\n * The options for the function that actually serves a file.\n *\n * @group Services/SendFile\n */\nexport type SendFileOptions = {\n /**\n * The response object sent by the application. Necessary to write the file.\n */\n res: Response;\n /**\n * The path of the file to serve. Depending on the `from` option, it will be either\n * relative to the project root, or the application executable.\n */\n filepath: string;\n /**\n * The name of a location on the `pathUtils` service from where the `filepath` is\n * relative to. It can be `app` for the directory containing the application executable,\n * or `project` for the project root. It could also be any other location that the\n * implementation may have registered.\n *\n * @default 'app'\n */\n from?: string;\n /**\n * The function to move to the next middleware. It can be used to report an error in\n * case the file can't be served.\n *\n * @default {() => {}}\n */\n next?: NextFunction;\n};\n/**\n * The type of the function that serves a file.\n * This is exported to make it easy to type the dependency injection.\n *\n * @group Services/SendFile\n */\nexport type SendFile = (options: SendFileOptions) => void;\n/**\n * Generates a function to send files on the application response.\n *\n * @param options To inject the required dependencies.\n * @example\n *\n * <caption>Basic usage</caption>\n *\n * // Let's say this is inside an Express middleware.\n * // Get the function\n * const send = sendFile(pathUtils);\n * send({ res, filepath: 'some-file.html', next });\n * // If your app is on \"/app/index.js\", this will send \"/app/some-file.html\".\n *\n * @group Services\n * @group Services/SendFile\n */\nexport const sendFile =\n ({ inject: { pathUtils } }: SendFileGeneratorOptions): SendFile =>\n ({ res, filepath, from = 'app', next = () => {} }) => {\n res.sendFile(pathUtils.joinFrom(from, filepath), (error) => {\n if (error) {\n next(error);\n } else {\n res.end();\n }\n });\n };\n\n/**\n * The service provider that once registered on the container will set the result of\n * {@link sendFile} as the `sendFile` service.\n *\n * @example\n *\n * // Register it on the container\n * container.register(sendFileProvider);\n * // Getting access to the service instance\n * const sendFile = container.get<SendFile>('sendFile');\n *\n * @group Providers\n * @group Services/SendFile\n */\nexport const sendFileProvider = provider((app) => {\n app.set('sendFile', () =>\n sendFile({\n inject: {\n pathUtils: app.get('pathUtils'),\n },\n }),\n );\n});\n"],"mappings":"AAAA,SAAS,gBAAgB;AAuElB,MAAM,WACX,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,MACzB,CAAC,EAAE,KAAK,UAAU,OAAO,OAAO,OAAO,MAAM;AAAC,EAAE,MAAM;AACpD,MAAI,SAAS,UAAU,SAAS,MAAM,QAAQ,GAAG,CAAC,UAAU;AAC1D,QAAI,OAAO;AACT,WAAK,KAAK;AAAA,IACZ,OAAO;AACL,UAAI,IAAI;AAAA,IACV;AAAA,EACF,CAAC;AACH;AAgBK,MAAM,mBAAmB,SAAS,CAAC,QAAQ;AAChD,MAAI;AAAA,IAAI;AAAA,IAAY,MAClB,SAAS;AAAA,MACP,QAAQ;AAAA,QACN,WAAW,IAAI,IAAI,WAAW;AAAA,MAChC;AAAA,IACF,CAAC;AAAA,EACH;AACF,CAAC;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-C6I3NCC-.js';
2
+ import { J as Jimpex } from '../../index-BlSpNHox.js';
3
3
  import { PathUtils } from '@homer0/path-utils';
4
- import fs from 'fs/promises';
4
+ import fs from 'node:fs/promises';
5
5
  import '../../types/express.js';
6
6
  import 'express';
7
7
  import '../../types/http.js';
@@ -1,50 +1,14 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
31
- var frontendFs_exports = {};
32
- __export(frontendFs_exports, {
33
- FrontendFs: () => FrontendFs,
34
- frontendFsProvider: () => frontendFsProvider
35
- });
36
- module.exports = __toCommonJS(frontendFs_exports);
37
- var import_promises = __toESM(require("fs/promises"));
38
- var import_utils = require("../../utils");
1
+ import fs from "node:fs/promises";
2
+ import { provider } from "../../utils/index.js";
39
3
  class FrontendFs {
4
+ /**
5
+ * The service that generates the relative paths.
6
+ */
7
+ _pathUtils;
40
8
  /**
41
9
  * @param options The options to construct the service.
42
10
  */
43
11
  constructor({ inject: { pathUtils } }) {
44
- /**
45
- * The service that generates the relative paths.
46
- */
47
- __publicField(this, "_pathUtils");
48
12
  this._pathUtils = pathUtils;
49
13
  }
50
14
  /**
@@ -53,7 +17,7 @@ class FrontendFs {
53
17
  * @param filepath The path to the file.
54
18
  */
55
19
  delete(filepath) {
56
- return import_promises.default.unlink(this.getAppPath(filepath));
20
+ return fs.unlink(this.getAppPath(filepath));
57
21
  }
58
22
  /**
59
23
  * Reads a file from the file system.
@@ -62,7 +26,7 @@ class FrontendFs {
62
26
  * @param encoding The text encoding in which the file should be read.
63
27
  */
64
28
  read(filepath, encoding = "utf-8") {
65
- return import_promises.default.readFile(this.getAppPath(filepath), encoding);
29
+ return fs.readFile(this.getAppPath(filepath), encoding);
66
30
  }
67
31
  /**
68
32
  * Writes a file on the file system.
@@ -71,7 +35,7 @@ class FrontendFs {
71
35
  * @param content The contents of the file.
72
36
  */
73
37
  write(filepath, content) {
74
- return import_promises.default.writeFile(this.getAppPath(filepath), content);
38
+ return fs.writeFile(this.getAppPath(filepath), content);
75
39
  }
76
40
  /**
77
41
  * Utility method to get the path of a file relative to the application executable.
@@ -82,7 +46,7 @@ class FrontendFs {
82
46
  return this._pathUtils.joinFrom("app", filepath);
83
47
  }
84
48
  }
85
- const frontendFsProvider = (0, import_utils.provider)((app) => {
49
+ const frontendFsProvider = provider((app) => {
86
50
  app.set(
87
51
  "frontendFs",
88
52
  () => new FrontendFs({
@@ -92,9 +56,8 @@ const frontendFsProvider = (0, import_utils.provider)((app) => {
92
56
  })
93
57
  );
94
58
  });
95
- // Annotate the CommonJS export names for ESM import in node:
96
- 0 && (module.exports = {
59
+ export {
97
60
  FrontendFs,
98
61
  frontendFsProvider
99
- });
62
+ };
100
63
  //# sourceMappingURL=frontendFs.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/services/frontend/frontendFs.ts"],"sourcesContent":["import fs from 'fs/promises';\nimport { provider } from '../../utils';\nimport type { PathUtils } from '../../types';\n/**\n * The options to construct a {@link FrontendFs}.\n *\n * @group Services/FrontendFs\n */\nexport type FrontendFsOptions = {\n /**\n * A dictionary with the dependencies to inject.\n */\n inject: {\n pathUtils: PathUtils;\n };\n};\n/**\n * This service allows the application to easily work with the filesystem. The idea behind\n * centralizing this functionalities into a service is that is pretty common to have\n * bundling tools to generate the frontend, and on that process files can have different\n * paths or not even be generated all. The service can be extended/overwritten to\n * accommodate any requirements and avoid having to update or add `if`s to every `fs` call\n * the application does.\n * Another _'feature'_ of this service is that all the paths are relative to the directory\n * where the app executable is located, so you don't have to remember the relative path\n * from the place you are accessing a file to the place where it's located.\n *\n * @group Services\n * @group Services/FrontendFs\n */\nexport class FrontendFs {\n /**\n * The service that generates the relative paths.\n */\n protected readonly _pathUtils: PathUtils;\n /**\n * @param options The options to construct the service.\n */\n constructor({ inject: { pathUtils } }: FrontendFsOptions) {\n this._pathUtils = pathUtils;\n }\n /**\n * Deletes a file from the file system.\n *\n * @param filepath The path to the file.\n */\n delete(filepath: string): Promise<void> {\n return fs.unlink(this.getAppPath(filepath));\n }\n /**\n * Reads a file from the file system.\n *\n * @param filepath The path to the file.\n * @param encoding The text encoding in which the file should be read.\n */\n read(filepath: string, encoding: BufferEncoding = 'utf-8'): Promise<string> {\n return fs.readFile(this.getAppPath(filepath), encoding);\n }\n /**\n * Writes a file on the file system.\n *\n * @param filepath The path to the file.\n * @param content The contents of the file.\n */\n write(filepath: string, content: Parameters<typeof fs.writeFile>[1]): Promise<void> {\n return fs.writeFile(this.getAppPath(filepath), content);\n }\n /**\n * Utility method to get the path of a file relative to the application executable.\n *\n * @param filepath The path to the file.\n */\n protected getAppPath(filepath: string): string {\n return this._pathUtils.joinFrom('app', filepath);\n }\n}\n/**\n * The service provider that once registered on the container will set an instance of\n * {@link FrontendFs} as the `frontendFs` service.\n *\n * @example\n *\n * // Register it on the container\n * container.register(frontendFsProvider);\n * // Getting access to the service instance\n * const frontendFs = container.get<FrontendFs>('frontendFs');\n *\n * @group Providers\n * @group Services/FrontendFs\n */\nexport const frontendFsProvider = provider((app) => {\n app.set(\n 'frontendFs',\n () =>\n new FrontendFs({\n inject: {\n pathUtils: app.get<PathUtils>('pathUtils'),\n },\n }),\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAe;AACf,mBAAyB;AA6BlB,MAAM,WAAW;AAAA;AAAA;AAAA;AAAA,EAQtB,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAsB;AAJ1D;AAAA;AAAA;AAAA,wBAAmB;AAKjB,SAAK,aAAa;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,UAAiC;AACtC,WAAO,gBAAAA,QAAG,OAAO,KAAK,WAAW,QAAQ,CAAC;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,KAAK,UAAkB,WAA2B,SAA0B;AAC1E,WAAO,gBAAAA,QAAG,SAAS,KAAK,WAAW,QAAQ,GAAG,QAAQ;AAAA,EACxD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,UAAkB,SAA4D;AAClF,WAAO,gBAAAA,QAAG,UAAU,KAAK,WAAW,QAAQ,GAAG,OAAO;AAAA,EACxD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMU,WAAW,UAA0B;AAC7C,WAAO,KAAK,WAAW,SAAS,OAAO,QAAQ;AAAA,EACjD;AACF;AAeO,MAAM,yBAAqB,uBAAS,CAAC,QAAQ;AAClD,MAAI;AAAA,IACF;AAAA,IACA,MACE,IAAI,WAAW;AAAA,MACb,QAAQ;AAAA,QACN,WAAW,IAAI,IAAe,WAAW;AAAA,MAC3C;AAAA,IACF,CAAC;AAAA,EACL;AACF,CAAC;","names":["fs"]}
1
+ {"version":3,"sources":["../../../src/services/frontend/frontendFs.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport { provider } from '../../utils/index.js';\nimport type { PathUtils } from '../../types/index.js';\n/**\n * The options to construct a {@link FrontendFs}.\n *\n * @group Services/FrontendFs\n */\nexport type FrontendFsOptions = {\n /**\n * A dictionary with the dependencies to inject.\n */\n inject: {\n pathUtils: PathUtils;\n };\n};\n/**\n * This service allows the application to easily work with the filesystem. The idea behind\n * centralizing this functionalities into a service is that is pretty common to have\n * bundling tools to generate the frontend, and on that process files can have different\n * paths or not even be generated all. The service can be extended/overwritten to\n * accommodate any requirements and avoid having to update or add `if`s to every `fs` call\n * the application does.\n * Another _'feature'_ of this service is that all the paths are relative to the directory\n * where the app executable is located, so you don't have to remember the relative path\n * from the place you are accessing a file to the place where it's located.\n *\n * @group Services\n * @group Services/FrontendFs\n */\nexport class FrontendFs {\n /**\n * The service that generates the relative paths.\n */\n protected readonly _pathUtils: PathUtils;\n /**\n * @param options The options to construct the service.\n */\n constructor({ inject: { pathUtils } }: FrontendFsOptions) {\n this._pathUtils = pathUtils;\n }\n /**\n * Deletes a file from the file system.\n *\n * @param filepath The path to the file.\n */\n delete(filepath: string): Promise<void> {\n return fs.unlink(this.getAppPath(filepath));\n }\n /**\n * Reads a file from the file system.\n *\n * @param filepath The path to the file.\n * @param encoding The text encoding in which the file should be read.\n */\n read(filepath: string, encoding: BufferEncoding = 'utf-8'): Promise<string> {\n return fs.readFile(this.getAppPath(filepath), encoding);\n }\n /**\n * Writes a file on the file system.\n *\n * @param filepath The path to the file.\n * @param content The contents of the file.\n */\n write(filepath: string, content: Parameters<typeof fs.writeFile>[1]): Promise<void> {\n return fs.writeFile(this.getAppPath(filepath), content);\n }\n /**\n * Utility method to get the path of a file relative to the application executable.\n *\n * @param filepath The path to the file.\n */\n protected getAppPath(filepath: string): string {\n return this._pathUtils.joinFrom('app', filepath);\n }\n}\n/**\n * The service provider that once registered on the container will set an instance of\n * {@link FrontendFs} as the `frontendFs` service.\n *\n * @example\n *\n * // Register it on the container\n * container.register(frontendFsProvider);\n * // Getting access to the service instance\n * const frontendFs = container.get<FrontendFs>('frontendFs');\n *\n * @group Providers\n * @group Services/FrontendFs\n */\nexport const frontendFsProvider = provider((app) => {\n app.set(\n 'frontendFs',\n () =>\n new FrontendFs({\n inject: {\n pathUtils: app.get<PathUtils>('pathUtils'),\n },\n }),\n );\n});\n"],"mappings":"AAAA,OAAO,QAAQ;AACf,SAAS,gBAAgB;AA6BlB,MAAM,WAAW;AAAA;AAAA;AAAA;AAAA,EAIH;AAAA;AAAA;AAAA;AAAA,EAInB,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAsB;AACxD,SAAK,aAAa;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,UAAiC;AACtC,WAAO,GAAG,OAAO,KAAK,WAAW,QAAQ,CAAC;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,KAAK,UAAkB,WAA2B,SAA0B;AAC1E,WAAO,GAAG,SAAS,KAAK,WAAW,QAAQ,GAAG,QAAQ;AAAA,EACxD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,UAAkB,SAA4D;AAClF,WAAO,GAAG,UAAU,KAAK,WAAW,QAAQ,GAAG,OAAO;AAAA,EACxD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMU,WAAW,UAA0B;AAC7C,WAAO,KAAK,WAAW,SAAS,OAAO,QAAQ;AAAA,EACjD;AACF;AAeO,MAAM,qBAAqB,SAAS,CAAC,QAAQ;AAClD,MAAI;AAAA,IACF;AAAA,IACA,MACE,IAAI,WAAW;AAAA,MACb,QAAQ;AAAA,QACN,WAAW,IAAI,IAAe,WAAW;AAAA,MAC3C;AAAA,IACF,CAAC;AAAA,EACL;AACF,CAAC;","names":[]}
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-C6I3NCC-.js';
2
+ import { J as Jimpex } from '../../index-BlSpNHox.js';
3
3
  export { FrontendFs, FrontendFsOptions, frontendFsProvider } from './frontendFs.js';
4
4
  import '../../types/express.js';
5
5
  import 'express';
@@ -13,7 +13,7 @@ import '@homer0/path-utils';
13
13
  import '@homer0/simple-logger';
14
14
  import '@homer0/simple-config';
15
15
  import '@homer0/events-hub';
16
- import 'fs/promises';
16
+ import 'node:fs/promises';
17
17
 
18
18
  /**
19
19
  * Registers all the frontend services on the container.
@@ -1,36 +1,10 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var frontend_exports = {};
21
- __export(frontend_exports, {
22
- frontendServicesProvider: () => frontendServicesProvider
23
- });
24
- module.exports = __toCommonJS(frontend_exports);
25
- var import_utils = require("../../utils");
26
- var import_frontendFs = require("./frontendFs");
27
- __reExport(frontend_exports, require("./frontendFs"), module.exports);
28
- const frontendServicesProvider = (0, import_utils.providers)({
29
- frontendFsProvider: import_frontendFs.frontendFsProvider
30
- });
31
- // Annotate the CommonJS export names for ESM import in node:
32
- 0 && (module.exports = {
33
- frontendServicesProvider,
34
- ...require("./frontendFs")
1
+ import { providers } from "../../utils/index.js";
2
+ import { frontendFsProvider } from "./frontendFs.js";
3
+ const frontendServicesProvider = providers({
4
+ frontendFsProvider
35
5
  });
6
+ export * from "./frontendFs.js";
7
+ export {
8
+ frontendServicesProvider
9
+ };
36
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/services/frontend/index.ts"],"sourcesContent":["import { providers } from '../../utils';\nimport { frontendFsProvider } from './frontendFs';\n/**\n * Registers all the frontend services on the container.\n *\n * - {@link FrontendFs | frontendFs}\n *\n * @example\n *\n * // Register the collection on the container\n * container.register(frontendServicesProvider);\n * // Getting access to one the services instance\n * const frontendFs = container.get<FrontendFs>('frontendFs');\n *\n * @group Providers\n */\nexport const frontendServicesProvider = providers({\n frontendFsProvider,\n});\n\nexport * from './frontendFs';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;AAC1B,wBAAmC;AAmBnC,6BAAc,yBApBd;AAgBO,MAAM,+BAA2B,wBAAU;AAAA,EAChD;AACF,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../../src/services/frontend/index.ts"],"sourcesContent":["import { providers } from '../../utils/index.js';\nimport { frontendFsProvider } from './frontendFs.js';\n/**\n * Registers all the frontend services on the container.\n *\n * - {@link FrontendFs | frontendFs}\n *\n * @example\n *\n * // Register the collection on the container\n * container.register(frontendServicesProvider);\n * // Getting access to one the services instance\n * const frontendFs = container.get<FrontendFs>('frontendFs');\n *\n * @group Providers\n */\nexport const frontendServicesProvider = providers({\n frontendFsProvider,\n});\n\nexport * from './frontendFs.js';\n"],"mappings":"AAAA,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AAe5B,MAAM,2BAA2B,UAAU;AAAA,EAChD;AACF,CAAC;AAED,cAAc;","names":[]}
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-C6I3NCC-.js';
2
+ import { J as Jimpex } from '../../index-BlSpNHox.js';
3
3
  import { SimpleLogger } from '@homer0/simple-logger';
4
4
  import { SimpleConfig } from '@homer0/simple-config';
5
5
  import { FrontendFs } from '../frontend/frontendFs.js';
@@ -14,7 +14,7 @@ import 'node-fetch';
14
14
  import '../../types/utils.js';
15
15
  import '@homer0/path-utils';
16
16
  import '@homer0/events-hub';
17
- import 'fs/promises';
17
+ import 'node:fs/promises';
18
18
 
19
19
  /**
20
20
  * The options to customize a {@link HTMLGenerator} instance.
@@ -41,7 +41,7 @@ type HTMLGeneratorOptions = {
41
41
  */
42
42
  silent: boolean;
43
43
  /**
44
- * Whether or not to delete the tempalte after generating the file.
44
+ * Whether or not to delete the template after generating the file.
45
45
  *
46
46
  * @default true
47
47
  */
@@ -49,7 +49,7 @@ type HTMLGeneratorOptions = {
49
49
  /**
50
50
  * The placeholder string where the information will be written.
51
51
  *
52
- * @default /\{\{appConfi(?:guration)?\}\}/
52
+ * @default /\{\{appConfig(?:uration)?\}\}/
53
53
  */
54
54
  replacePlaceholder: string | RegExp;
55
55
  /**
@@ -165,7 +165,7 @@ declare class HTMLGenerator {
165
165
  protected _fileReady: boolean;
166
166
  /**
167
167
  * A deferred promise to return when another service asks if the file has been
168
- * generated. Once this sevice finishes generating the file, the promise will be
168
+ * generated. Once this service finishes generating the file, the promise will be
169
169
  * resolved for all implementations that hold a reference to this deferred.
170
170
  */
171
171
  protected _fileDeferred?: DeferredPromise<void>;