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,6 +1,6 @@
1
- export * from './events';
2
- export * from './express';
3
- export * from './http';
4
- export * from './options';
5
- export * from './utils';
6
- export * from './wootils';
1
+ export * from './events.js';
2
+ export * from './express.js';
3
+ export * from './http.js';
4
+ export * from './options.js';
5
+ export * from './utils.js';
6
+ export * from './wootils.js';
@@ -1,5 +1,5 @@
1
- import type { Config } from './wootils';
2
- import type { Jimpex } from '../app';
1
+ import type { Config } from './wootils.js';
2
+ import type { Jimpex } from '../app/index.js';
3
3
  /**
4
4
  * The options for the application's configuration service.
5
5
  *
@@ -14,8 +14,8 @@ export type DeepPartial<T> = {
14
14
  [P in keyof T]?: T[P] extends (infer U)[]
15
15
  ? DeepPartial<U>[]
16
16
  : T[P] extends object
17
- ? DeepPartial<T[P]>
18
- : T[P];
17
+ ? DeepPartial<T[P]>
18
+ : T[P];
19
19
  };
20
20
  /**
21
21
  * Utility to make a deep "readonly" of an existing type.
@@ -27,8 +27,8 @@ export type DeepReadonly<T> = {
27
27
  readonly [P in keyof T]: T[P] extends (infer U)[]
28
28
  ? DeepReadonly<U>[]
29
29
  : T[P] extends object
30
- ? DeepReadonly<T[P]>
31
- : T[P];
30
+ ? DeepReadonly<T[P]>
31
+ : T[P];
32
32
  };
33
33
  /**
34
34
  * Utility to remove string indexes from types.
@@ -1,4 +1,4 @@
1
- export * from './others';
2
- export * from './routes';
3
- export * from './statuses';
4
- export * from './text';
1
+ export * from './others.js';
2
+ export * from './routes.js';
3
+ export * from './statuses.js';
4
+ export * from './text.js';
@@ -1,4 +1,4 @@
1
- import { escapeForRegExp } from './text';
1
+ import { escapeForRegExp } from './text.js';
2
2
 
3
3
  /**
4
4
  * Removes any leading slash from a URL.
@@ -1,2 +1,2 @@
1
- export * from './fns';
2
- export * from './wrappers';
1
+ export * from './fns/index.js';
2
+ export * from './wrappers.js';
@@ -7,8 +7,8 @@ import {
7
7
  type GenericCurriedFn,
8
8
  resourceCreatorFactory,
9
9
  } from '@homer0/jimple';
10
- import type { Jimpex } from '../app';
11
- import type { Router, ExpressMiddlewareLike, NoStringIndex } from '../types';
10
+ import type { Jimpex } from '../app/index.js';
11
+ import type { Router, ExpressMiddlewareLike, NoStringIndex } from '../types/index.js';
12
12
  /**
13
13
  * The function a provider uses to configure a resource in the container.
14
14
  *
@@ -303,9 +303,9 @@ export type ControllerProviderCreator = ReturnType<typeof controllerProviderCrea
303
303
  *
304
304
  * @param container The reference to the Jimpex container.
305
305
  * @param route This is optional because the implementation can use it as a
306
- * "global widdleware", or for a specific route.
307
- * @returns The resource can choose to be enabled or not by returning the function, or
308
- * `undefined`.
306
+ * "global middleware", or for a specific route.
307
+ * @returns The resource can choose to be enabled or not by returning the function,
308
+ * or `undefined`.
309
309
  * @group Wrappers
310
310
  */
311
311
  export type MiddlewareConnectFn = <ContainerType extends Jimpex = Jimpex>(
@@ -399,7 +399,7 @@ export type MiddlewareCreator = ReturnType<typeof middlewareCreator>;
399
399
 
400
400
  // --
401
401
  /**
402
- * The function a middelware provider uses to configure/extend the container before
402
+ * The function a middleware provider uses to configure/extend the container before
403
403
  * returning an actual middleware.
404
404
  *
405
405
  * @param container The reference to the Jimpex container.
package/tsconfig.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "extends": "@homer0/tsconfig/tsconfig.node.json",
3
3
  "compilerOptions": {
4
- "outDir": "dist",
5
- "emitDecoratorMetadata": false,
6
- "incremental": false
4
+ "outDir": "dist"
7
5
  },
8
- "include": ["src/**/*.ts", "examples/**/*.ts", "tsup.config.ts"]
6
+ "include": [
7
+ "src/**/*.ts",
8
+ "examples/**/*.ts",
9
+ "tsup.config.ts",
10
+ "vitest.config.ts",
11
+ ".prettierrc.js",
12
+ "eslint.config.js"
13
+ ]
9
14
  }
package/tsup.config.ts CHANGED
@@ -3,8 +3,7 @@ import { defineConfig } from 'tsup';
3
3
  export default defineConfig({
4
4
  sourcemap: true,
5
5
  clean: true,
6
- format: ['esm', 'cjs'],
7
- legacyOutput: true,
6
+ format: ['esm'],
8
7
  dts: true,
9
8
  bundle: false,
10
9
  });
@@ -0,0 +1,24 @@
1
+ import { resolve } from 'node:path';
2
+ import { defineConfig, type Plugin } from 'vitest/config';
3
+ import swc from 'unplugin-swc';
4
+ import tsconfigPaths from 'vite-tsconfig-paths';
5
+
6
+ export default defineConfig({
7
+ plugins: [
8
+ tsconfigPaths(),
9
+ swc.vite({
10
+ module: { type: 'es6' },
11
+ }) as Plugin,
12
+ ],
13
+ test: {
14
+ environment: 'node',
15
+ include: ['tests/**/*.test.ts'],
16
+ globals: true,
17
+ coverage: {
18
+ provider: 'istanbul',
19
+ reportsDirectory: resolve('./coverage'),
20
+ reporter: ['text', 'lcov'],
21
+ exclude: ['tests/mocks/**', 'utils/scripts/**'],
22
+ },
23
+ },
24
+ });
@@ -1,14 +0,0 @@
1
- export { J as Jimpex, j as jimpex } from '../index-Bwf7JHu9.mjs';
2
- import '../types/express.mjs';
3
- import 'express';
4
- import '../types/http.mjs';
5
- import 'https';
6
- import 'http';
7
- import 'spdy';
8
- import 'node-fetch';
9
- import '../types/utils.mjs';
10
- import '@homer0/path-utils';
11
- import '@homer0/simple-logger';
12
- import '@homer0/simple-config';
13
- import '@homer0/events-hub';
14
- import '@homer0/jimple';
@@ -1,14 +0,0 @@
1
- import '@homer0/jimple';
2
- import '@homer0/events-hub';
3
- export { J as Jimpex, j as jimpex } from '../index-Bwf7JHu9.mjs';
4
- import 'express';
5
- import '../types/http.mjs';
6
- import '../types/utils.mjs';
7
- import '@homer0/simple-logger';
8
- import '@homer0/simple-config';
9
- import '../types/express.mjs';
10
- import '@homer0/path-utils';
11
- import 'node-fetch';
12
- import 'https';
13
- import 'http';
14
- import 'spdy';
@@ -1,79 +0,0 @@
1
- import * as _homer0_jimple from '@homer0/jimple';
2
- import { C as ControllerConnectFn } from '../../index-Bwf7JHu9.mjs';
3
- import { ExpressMiddleware, AsyncExpressMiddleware } from '../../types/express.mjs';
4
- import { SimpleConfig } from '@homer0/simple-config';
5
- import { ResponsesBuilder } from '../../services/http/responsesBuilder.mjs';
6
- import { Response } 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/events-hub';
16
- import '../../utils/fns/statuses.mjs';
17
- import 'statuses';
18
-
19
- /**
20
- * The options to contruct a {@link ConfigController}.
21
- *
22
- * @group Controllers/Config
23
- */
24
- type ConfigControllerOptions = {
25
- /**
26
- * A dictionary with the dependencies to inject.
27
- */
28
- inject: {
29
- responsesBuilder: ResponsesBuilder;
30
- config: SimpleConfig;
31
- };
32
- };
33
- /**
34
- * The controller class that allows to show and switch the application configuration.
35
- *
36
- * @group Controller Classes
37
- * @group Controllers/Config
38
- * @prettierignore
39
- */
40
- declare class ConfigController {
41
- /**
42
- * The service in charge or building the responses.
43
- */
44
- protected readonly _responsesBuilder: ResponsesBuilder;
45
- /**
46
- * The service in charge of the configuration.
47
- */
48
- protected readonly _config: SimpleConfig;
49
- /**
50
- * @param options The options to construct the controller.
51
- */
52
- constructor({ inject }: ConfigControllerOptions);
53
- /**
54
- * Creates the middleware the shows the current configuration.
55
- */
56
- showConfig(): ExpressMiddleware;
57
- /**
58
- * Creates the middleware the allows to switch the configuration.
59
- */
60
- switchConfig(): AsyncExpressMiddleware;
61
- /**
62
- * Utility to respond with the current configuration.
63
- */
64
- protected respondWithConfig(res: Response): void;
65
- }
66
- /**
67
- * This controller is kind of special as it will only mount the routes if the
68
- * `debug.configController` setting of the app configuration is set to `true`.
69
- *
70
- * It provides routes for:
71
- * - `/`: Showing the current configuration.
72
- * - `/switch/:name`: Switching the configuration, but only if the service allows it.
73
- *
74
- * @group Controllers
75
- * @group Controllers/Config
76
- */
77
- declare const configController: _homer0_jimple.Resource<"controller", "connect", ControllerConnectFn>;
78
-
79
- export { ConfigController, type ConfigControllerOptions, configController };
@@ -1,83 +0,0 @@
1
- import * as _homer0_jimple from '@homer0/jimple';
2
- import { Statuses } from '../../utils/fns/statuses.mjs';
3
- import { r as JimpexHealthStatus, C as ControllerConnectFn } from '../../index-Bwf7JHu9.mjs';
4
- import { AsyncExpressMiddleware } from '../../types/express.mjs';
5
- import { SimpleConfig } from '@homer0/simple-config';
6
- import { ResponsesBuilder } from '../../services/http/responsesBuilder.mjs';
7
- import 'statuses';
8
- import '../../types/http.mjs';
9
- import 'https';
10
- import 'http';
11
- import 'spdy';
12
- import 'node-fetch';
13
- import 'express';
14
- import '../../types/utils.mjs';
15
- import '@homer0/path-utils';
16
- import '@homer0/simple-logger';
17
- import '@homer0/events-hub';
18
-
19
- /**
20
- * A function that will return the health status of the application.
21
- *
22
- * @group Controllers/Health
23
- */
24
- type GetHealthStatus = () => Promise<JimpexHealthStatus>;
25
- /**
26
- * The options to contruct a {@link HealthController}.
27
- *
28
- * @group Controllers/Health
29
- */
30
- type HealthControllerOptions = {
31
- /**
32
- * A dictionary with the dependencies to inject.
33
- */
34
- inject: {
35
- getHealthStatus: GetHealthStatus;
36
- responsesBuilder: ResponsesBuilder;
37
- config: SimpleConfig;
38
- statuses: Statuses;
39
- };
40
- };
41
- /**
42
- * The controller class that shows the application health status.
43
- *
44
- * @group Controller Classes
45
- * @group Controllers/Health
46
- * @prettierignore
47
- */
48
- declare class HealthController {
49
- /**
50
- * The function that returns the health status of the application.
51
- */
52
- protected readonly _getHealthStatus: GetHealthStatus;
53
- /**
54
- * The service in charge or building the responses.
55
- */
56
- protected readonly _responsesBuilder: ResponsesBuilder;
57
- /**
58
- * The service in charge of the configuration.
59
- */
60
- protected readonly _config: SimpleConfig;
61
- /**
62
- * The uility service to get HTTP status codes.
63
- */
64
- protected readonly _statuses: Statuses;
65
- /**
66
- * @param options The options to construct the controller.
67
- */
68
- constructor({ inject }: HealthControllerOptions);
69
- /**
70
- * Creates the middleware the shows the application health status.
71
- */
72
- showHealth(): AsyncExpressMiddleware;
73
- }
74
- /**
75
- * The controller that once mounted, it will add an endpoint to show the application
76
- * health status.
77
- *
78
- * @group Controllers
79
- * @group Controllers/Health
80
- */
81
- declare const healthController: _homer0_jimple.Resource<"controller", "connect", ControllerConnectFn>;
82
-
83
- export { type GetHealthStatus, HealthController, type HealthControllerOptions, healthController };
@@ -1,22 +0,0 @@
1
- export { ConfigController, ConfigControllerOptions, configController } from './config.mjs';
2
- export { GetHealthStatus, HealthController, HealthControllerOptions, healthController } from './health.mjs';
3
- export { AddStaticRouteOptions, StaticsController, StaticsControllerConstructorOptions, StaticsControllerCreatorOptions, StaticsControllerFile, StaticsControllerGetMiddlewaresFn, StaticsControllerOptions, StaticsControllerPathsOptions, staticsController } from './statics.mjs';
4
- import '@homer0/jimple';
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/http/responsesBuilder.mjs';
19
- import '../../utils/fns/statuses.mjs';
20
- import 'statuses';
21
- import 'mime';
22
- import '../../services/common/sendFile.mjs';
@@ -1,223 +0,0 @@
1
- import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex, a1 as MiddlewareLike, C as ControllerConnectFn } from '../../index-Bwf7JHu9.mjs';
3
- import mime from 'mime';
4
- import { RouterMethod, ExpressMiddleware } from '../../types/express.mjs';
5
- import { DeepPartial } from '../../types/utils.mjs';
6
- import { SendFile } from '../../services/common/sendFile.mjs';
7
- import { Router } from 'express';
8
- import '../../types/http.mjs';
9
- import 'https';
10
- import 'http';
11
- import 'spdy';
12
- import 'node-fetch';
13
- import '@homer0/path-utils';
14
- import '@homer0/simple-logger';
15
- import '@homer0/simple-config';
16
- import '@homer0/events-hub';
17
-
18
- type Mime = typeof mime;
19
- /**
20
- * The definition for each file the controller handles.
21
- *
22
- * @group Controllers/Statics
23
- */
24
- type StaticsControllerFile = {
25
- /**
26
- * The route, relative to the controller root, to the file.
27
- */
28
- route: string;
29
- /**
30
- * The path to the file in the filesystem. Since the file is served using the
31
- * {@link SendFile} service, whether the file is relative to the project root or the
32
- * application executable depends on how the service is configured (relative to the
33
- * executable by default).
34
- */
35
- path: string;
36
- /**
37
- * A dictionary of headers for the response.
38
- */
39
- headers?: Record<string, string>;
40
- };
41
- /**
42
- * These are like "master paths" that get prepended to all the file paths and routes the
43
- * controller use.
44
- *
45
- * @group Controllers/Statics
46
- */
47
- type StaticsControllerPathsOptions = {
48
- /**
49
- * A custom route to prefix all the file routes with.
50
- */
51
- route: string;
52
- /**
53
- * A custom path to prefix all the file paths with.
54
- */
55
- source: string;
56
- };
57
- /**
58
- * The options to customize the controller.
59
- *
60
- * @group Controllers/Statics
61
- */
62
- type StaticsControllerOptions = {
63
- /**
64
- * A list of filenames, or definitions for the files to handle.
65
- */
66
- files: Array<string | StaticsControllerFile>;
67
- /**
68
- * A dictionary with the allowed router (HTTP) methods the controller can use to serve
69
- * the files. If `all` is set to `true`, the rest of the values will be ignored.
70
- *
71
- * @default {get: true, all: false}
72
- */
73
- methods: Partial<Record<RouterMethod, boolean>>;
74
- /**
75
- * The "master paths" the controller can use to prefix the file paths and routes.
76
- *
77
- * @default {route: '', source: './',}
78
- */
79
- paths: StaticsControllerPathsOptions;
80
- };
81
- /**
82
- * The options to construct a {@link StaticsController}.
83
- *
84
- * @group Controllers/Statics
85
- */
86
- type StaticsControllerConstructorOptions = DeepPartial<StaticsControllerOptions> & {
87
- /**
88
- * A dictionary with the dependencies to inject.
89
- */
90
- inject: {
91
- sendFile: SendFile;
92
- mime: Mime;
93
- };
94
- };
95
- /**
96
- * A function to generate a list of middlewares that can be executed before the tontroller
97
- * main middleware.
98
- *
99
- * @group Controllers/Statics
100
- */
101
- type StaticsControllerGetMiddlewaresFn = (app: Jimpex) => MiddlewareLike[];
102
- /**
103
- * The options for the controller creator that mounts {@link StaticsController}.
104
- *
105
- * @group Controllers/Statics
106
- */
107
- type StaticsControllerCreatorOptions = DeepPartial<StaticsControllerOptions> & {
108
- /**
109
- * A function to generate a list of middlewares that can be executed before the
110
- * tontroller main middleware.
111
- */
112
- getMiddlewares?: StaticsControllerGetMiddlewaresFn;
113
- };
114
- /**
115
- * The options for {@link StaticsController._addRoute}.
116
- *
117
- * @access protected
118
- * @group Controllers/Statics
119
- */
120
- type AddStaticRouteOptions = {
121
- /**
122
- * The reference for the router in which the middlewares will be added.
123
- */
124
- router: Router;
125
- /**
126
- * The router method in which the middlewares will be added.
127
- */
128
- method: RouterMethod;
129
- /**
130
- * The definition of the file to serve.
131
- */
132
- file: StaticsControllerFile;
133
- /**
134
- * The middleware created by {@link StaticsController}, that will serve the file.
135
- */
136
- fileMiddleware: ExpressMiddleware;
137
- /**
138
- * A list of extra middlewares to execute before the file middleware.
139
- */
140
- middlewares: ExpressMiddleware[];
141
- };
142
- /**
143
- * The controller class that allows the application to serve specific files from any
144
- * folder to any route without the need of mounting directories as "static".
145
- *
146
- * @group Controller Classes
147
- * @group Controllers/Statics
148
- * @prettierignore
149
- */
150
- declare class StaticsController {
151
- /**
152
- * The service that serves static files.
153
- */
154
- protected readonly _sendFile: SendFile;
155
- /**
156
- * The MIME type library. Since it's an ESM only module, Jimpex loads it on boot and makes
157
- * it available on the container.
158
- */
159
- protected readonly _mime: Mime;
160
- /**
161
- * The controller customization options.
162
- */
163
- protected _options: StaticsControllerOptions;
164
- /**
165
- * A dictionary with the formatted definitions of the files that will be served.
166
- * It uses the files' routes as keys, for easy access in the middleware.
167
- */
168
- protected files: Record<string, StaticsControllerFile>;
169
- /**
170
- * @param options The options to construct the controller.
171
- */
172
- constructor({ inject, ...options }: StaticsControllerConstructorOptions);
173
- /**
174
- * Mounts the middlewares in the router in order to serve the files.
175
- *
176
- * @param router A reference to the application router.
177
- * @param middlewares A list of extra middlewares to execute before the file
178
- * middleware.
179
- */
180
- addRoutes(router: Router, middlewares?: ExpressMiddleware[]): Router;
181
- /**
182
- * The controller options.
183
- */
184
- get options(): Readonly<StaticsControllerOptions>;
185
- /**
186
- * Generates the middleware that will serve the file.
187
- *
188
- * @param file The definition of the file to serve.
189
- */
190
- protected _getMiddleware(file: StaticsControllerFile): ExpressMiddleware;
191
- /**
192
- * Mounts the middleware(s) for a file in the router.
193
- *
194
- * @param options The information of the file and how it needs to be added.
195
- */
196
- protected _addRoute({ router, method, file, fileMiddleware, middlewares, }: AddStaticRouteOptions): void;
197
- /**
198
- * Validates and formats the options sent to the constructor in order to get the final
199
- * set that will be stored in the controller.
200
- *
201
- * @param options The options to validate.
202
- * @throws If no files are specified.
203
- * @throws If methods is not defined.
204
- * @throws If no methods are enabled.
205
- * @throws If there's an invalid HTTP method.
206
- */
207
- protected _validateOptions(options: StaticsControllerOptions): StaticsControllerOptions;
208
- /**
209
- * Parses the files received from the constructor's options, and formats them into
210
- * proper definitions the controller can use.
211
- */
212
- protected _createFiles(): Record<string, StaticsControllerFile>;
213
- }
214
- /**
215
- * A controller that allows the application to server specific files from any folder to
216
- * any route without the need of mounting directories as "static" folders.
217
- *
218
- * @group Controllers
219
- * @group Controllers/Statics
220
- */
221
- declare const staticsController: _homer0_jimple.ResourceCreator<"controller", "connect", ({ getMiddlewares, ...options }?: StaticsControllerCreatorOptions) => <ContainerType extends Jimpex = Jimpex>(app: ContainerType) => Router, ControllerConnectFn>;
222
-
223
- export { type AddStaticRouteOptions, StaticsController, type StaticsControllerConstructorOptions, type StaticsControllerCreatorOptions, type StaticsControllerFile, type StaticsControllerGetMiddlewaresFn, type StaticsControllerOptions, type StaticsControllerPathsOptions, staticsController };
@@ -1,25 +0,0 @@
1
- export { ConfigController, ConfigControllerOptions, configController } from './common/config.mjs';
2
- export { GetHealthStatus, HealthController, HealthControllerOptions, healthController } from './common/health.mjs';
3
- export { AddStaticRouteOptions, StaticsController, StaticsControllerConstructorOptions, StaticsControllerCreatorOptions, StaticsControllerFile, StaticsControllerGetMiddlewaresFn, StaticsControllerOptions, StaticsControllerPathsOptions, staticsController } from './common/statics.mjs';
4
- export { AddGatewayRouteOptions, GatewayConfig, GatewayConfigEndpointDefinition, GatewayConfigEndpointProps, GatewayConfigEndpoints, GatewayController, GatewayControllerAPIConfig, GatewayControllerAPIConfigOptions, GatewayControllerConstructorOptions, GatewayControllerCreatorOptions, GatewayControllerEndpointInfo, GatewayControllerExtraOptions, GatewayControllerGetMiddlewaresFn, GatewayControllerHeaderOptions, GatewayControllerHelperOptions, GatewayControllerOptions, GatewayControllerRequest, GatewayControllerRoute, GatewayControllerRouteMethod, GatewayHelperService, GatewayHelperServiceBaseFnOptions, GatewayHelperServiceErrorHandler, GatewayHelperServiceErrorHandlerOptions, GatewayHelperServiceRequestReducer, GatewayHelperServiceRequestReducerOptions, GatewayHelperServiceResponseHandler, GatewayHelperServiceResponseReducer, GatewayHelperServiceResponseReducerOptions, GatewayHelperServiceStreamVerification, gatewayController } from './utils/gateway.mjs';
5
- import '@homer0/jimple';
6
- import '../index-Bwf7JHu9.mjs';
7
- import '../types/express.mjs';
8
- import 'express';
9
- import '../types/http.mjs';
10
- import 'https';
11
- import 'http';
12
- import 'spdy';
13
- import 'node-fetch';
14
- import '../types/utils.mjs';
15
- import '@homer0/path-utils';
16
- import '@homer0/simple-logger';
17
- import '@homer0/simple-config';
18
- import '@homer0/events-hub';
19
- import '../services/http/responsesBuilder.mjs';
20
- import '../utils/fns/statuses.mjs';
21
- import 'statuses';
22
- import 'mime';
23
- import '../services/common/sendFile.mjs';
24
- import '@homer0/api-utils';
25
- import '../services/http/http.mjs';