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,182 +0,0 @@
1
- import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
3
- import { Request } from 'express';
4
- import { NodeFetch } from '../../types/http.mjs';
5
- import { SimpleLogger } from '@homer0/simple-logger';
6
- import { BodyInit, Response, RequestInit } from 'node-fetch';
7
- import '../../types/express.mjs';
8
- import '../../types/utils.mjs';
9
- import '@homer0/path-utils';
10
- import '@homer0/simple-config';
11
- import '@homer0/events-hub';
12
- import 'https';
13
- import 'http';
14
- import 'spdy';
15
-
16
- /**
17
- * The options to customize the service.
18
- *
19
- * @group Services/HTTP
20
- */
21
- type HTTPOptions = {
22
- /**
23
- * Whether or not the service should log the requests and their responses.
24
- */
25
- logRequests?: boolean;
26
- };
27
- /**
28
- * The options to construct a {@link HTTP}.
29
- *
30
- * @group Services/HTTP
31
- */
32
- type HTTPContructorOptions = Partial<HTTPOptions> & {
33
- /**
34
- * A dictionary with the dependencies to inject.
35
- */
36
- inject: {
37
- logger: SimpleLogger;
38
- nodeFetch: NodeFetch;
39
- };
40
- };
41
- /**
42
- * The allowed formats for the body of a request.
43
- *
44
- * @group Services/HTTP
45
- */
46
- type HTTPFetchBody = string | Record<string | number, unknown> | BodyInit;
47
- /**
48
- * The options for a request.
49
- *
50
- * @group Services/HTTP
51
- */
52
- type HTTPFetchOptions = {
53
- /**
54
- * The HTTP method.
55
- *
56
- * @default 'GET'
57
- */
58
- method?: string;
59
- /**
60
- * The headers dictionary.
61
- */
62
- headers?: Record<string, string>;
63
- /**
64
- * The body of the request.
65
- */
66
- body?: HTTPFetchBody;
67
- /**
68
- * A dictionary of query string parameters.
69
- */
70
- qs?: Record<string, unknown>;
71
- /**
72
- * A request object generated by the application. This can be used to copy information
73
- * like custom headers or the IP (for the X-Forwarded-For header).
74
- */
75
- req?: Request;
76
- };
77
- /**
78
- * The options for the method that extracts custom headers from a request.
79
- *
80
- * @group Services/HTTP
81
- */
82
- type GetCustomHeadersFromRequestOptions = {
83
- /**
84
- * Since the method considers all headers that start with `x-` as custom headers,
85
- * setting this to `false` is the only way to exclude `x-forwarded-` headers from the
86
- * list.
87
- *
88
- * @default false
89
- */
90
- includeXForwardedHeaders?: boolean;
91
- };
92
- /**
93
- * A set of utilities to work with HTTP requests and responses.
94
- *
95
- * @group Services
96
- * @group Services/HTTP
97
- */
98
- declare class HTTP {
99
- /**
100
- * The service used to log information in the terminal.
101
- */
102
- protected readonly _logger: SimpleLogger;
103
- /**
104
- * The node-fetch library. Since it's an ESM only module, Jimpex loads it on boot and makes
105
- * it available on the container.
106
- */
107
- protected readonly _nodeFetch: NodeFetch;
108
- /**
109
- * The service customization options.
110
- */
111
- protected readonly _options: HTTPOptions;
112
- /**
113
- * @param options The options to construct the class.
114
- */
115
- constructor({ inject: { logger, nodeFetch }, ...options }: HTTPContructorOptions);
116
- /**
117
- * Makes a fetch request.
118
- *
119
- * @param url The URL to fetch.
120
- * @param options The custom options for the request.
121
- */
122
- fetch(url: string, options?: HTTPFetchOptions): Promise<Response>;
123
- /**
124
- * Tries to get the IP address from a given request.
125
- *
126
- * @param req The request from which it will try to obtain the IP address.
127
- */
128
- getIPFromRequest(req: Request): string | undefined;
129
- /**
130
- * Creates a dictionary with all the custom headers a request has. By custom header it
131
- * means all the headers which name start with `x-`.
132
- *
133
- * @param req The request from which it will try to get the headers.
134
- * @param options The options to customize the behavior with certain headers.
135
- */
136
- getCustomHeadersFromRequest(req: Request, options?: GetCustomHeadersFromRequestOptions): Record<string, string>;
137
- /**
138
- * It takes a dictionary of headers and normalize the names so each word will start with
139
- * an upper case character. This is helpful in case you added custom headers and didn't
140
- * care about the casing, or when copying headers from a server request, as they all
141
- * come tranformed into lower case.
142
- *
143
- * @param headers The dictionary of headers to normalize.
144
- */
145
- normalizeHeaders(headers: Record<string, string>): Record<string, string>;
146
- /**
147
- * The customization options.
148
- */
149
- get options(): Readonly<HTTPOptions>;
150
- /**
151
- * Logs a request information into the terminal.
152
- *
153
- * @param url The request URL.
154
- * @param options The options for the request.
155
- */
156
- protected _logRequest(url: string, options: RequestInit): void;
157
- /**
158
- * Logs a response information into the terminal.
159
- *
160
- * @param response The response to log.
161
- */
162
- protected _logResponse(response: Response): void;
163
- }
164
- /**
165
- * The service provider that once registered on the container will set an instance of
166
- * {@link HTTP} as the `http` service. The provider also checks the `debug.logRequests`
167
- * setting on the application configuration in order to enable or not the logging of
168
- * requests/responses.
169
- *
170
- * @example
171
- *
172
- * // Register it on the container
173
- * container.register(httpProvider);
174
- * // Getting access to the service instance
175
- * const http = container.get<HTTP>('http');
176
- *
177
- * @group Providers
178
- * @group Services/HTTP
179
- */
180
- declare const httpProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
181
-
182
- export { type GetCustomHeadersFromRequestOptions, HTTP, type HTTPContructorOptions, type HTTPFetchBody, type HTTPFetchOptions, type HTTPOptions, httpProvider };
@@ -1,51 +0,0 @@
1
- import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
3
- export { ErrorResponse } from '@homer0/api-utils';
4
- import { APIClientProviderOptions } from './apiClient.mjs';
5
- export { APIClient, APIClientConfig, APIClientConstructorOptions, APIClientSettings, EndpointsType, apiClientProvider } from './apiClient.mjs';
6
- export { GetCustomHeadersFromRequestOptions, HTTP, HTTPContructorOptions, HTTPFetchBody, HTTPFetchOptions, HTTPOptions, httpProvider } from './http.mjs';
7
- export { HTMLPostMessageResponseOptions, JSONResponseOptions, ResponsesBuilder, ResponsesBuilderConstructorOptions, responsesBuilderProvider } from './responsesBuilder.mjs';
8
- import '../../types/express.mjs';
9
- import 'express';
10
- import '../../types/http.mjs';
11
- import 'https';
12
- import 'http';
13
- import 'spdy';
14
- import 'node-fetch';
15
- import '../../types/utils.mjs';
16
- import '@homer0/path-utils';
17
- import '@homer0/simple-logger';
18
- import '@homer0/simple-config';
19
- import '@homer0/events-hub';
20
- import '../common/httpError.mjs';
21
- import '../../utils/fns/statuses.mjs';
22
- import 'statuses';
23
- import '../common/appError.mjs';
24
-
25
- /**
26
- * Registers all the HTTP services on the container.
27
- *
28
- * - {@link APIClient | apiClient}
29
- * - {@link HTTP | http}
30
- * - {@link ResponsesBuilder | responsesBuilder}
31
- *
32
- * @example
33
- *
34
- * // Register the collection on the container
35
- * container.register(httpServicesProvider);
36
- * // Getting access to one the services instance
37
- * const apiClient = container.get<APIClient>('apiClient');
38
- *
39
- * @group Providers
40
- */
41
- declare const httpServicesProvider: {
42
- apiClientProvider: _homer0_jimple.ResourceCreator<"provider", "register", (options?: APIClientProviderOptions) => (app: Jimpex) => void, _homer0_jimple.ProviderRegisterFn<Jimpex>>;
43
- httpProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
44
- responsesBuilderProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
45
- } & Record<string, _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>> & {
46
- provider: true;
47
- } & {
48
- register: _homer0_jimple.ProviderRegisterFn<Jimpex>;
49
- } & Record<string, unknown>;
50
-
51
- export { APIClientProviderOptions, httpServicesProvider };
@@ -1,179 +0,0 @@
1
- import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
3
- import { Response } from 'express';
4
- import { Statuses } from '../../utils/fns/statuses.mjs';
5
- import { SimpleConfig } from '@homer0/simple-config';
6
- import '../../types/express.mjs';
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 'statuses';
17
-
18
- /**
19
- * The options to construct a {@link ResponsesBuilder}.
20
- *
21
- * @group Services/ResponsesBuilder
22
- */
23
- type ResponsesBuilderConstructorOptions = {
24
- /**
25
- * A dictionary with the dependencies to inject.
26
- */
27
- inject: {
28
- config: SimpleConfig;
29
- statuses: Statuses;
30
- };
31
- };
32
- /**
33
- * The options to build a response for a post message.
34
- *
35
- * @group Services/ResponsesBuilder
36
- */
37
- type HTMLPostMessageResponseOptions = {
38
- /**
39
- * The response object generated by the application.
40
- */
41
- res: Response;
42
- /**
43
- * The title for the HTML.
44
- */
45
- title: string;
46
- /**
47
- * The contents of the post message.
48
- */
49
- message: string;
50
- /**
51
- * The status code for the response.
52
- *
53
- * @default 200
54
- */
55
- status?: number | string;
56
- /**
57
- * From which object will the `postMessage` method called from.
58
- *
59
- * @default 'window.opener'
60
- */
61
- target?: string;
62
- /**
63
- * Whether or not to call `window.close` after sending the message.
64
- *
65
- * @default true
66
- */
67
- close?: boolean;
68
- /**
69
- * In case `close` is set to `true`, this option is to specify how many milliseconds
70
- * should be waited before closing the window.
71
- *
72
- * @default 700
73
- */
74
- closeDelay?: number;
75
- };
76
- /**
77
- * The options to build a reponse for JSON.
78
- *
79
- * @group Services/ResponsesBuilder
80
- */
81
- type JSONResponseOptions = {
82
- /**
83
- * The response object generated by the application.
84
- */
85
- res: Response;
86
- /**
87
- * The actual data for the response. It will be added in a `data` property.
88
- */
89
- data: unknown;
90
- /**
91
- * The status code for the response.
92
- *
93
- * @default 200
94
- */
95
- status?: number | string;
96
- /**
97
- * Extra information to include inside the `metadata` object.
98
- */
99
- metadata?: object;
100
- };
101
- /**
102
- * A utility service to build responses.
103
- *
104
- * @group Services
105
- * @group Services/ResponsesBuilder
106
- */
107
- declare class ResponsesBuilder {
108
- /**
109
- * The application configuration, to get the `version` and the `postMessagesPrefix`.
110
- */
111
- protected readonly _config: SimpleConfig;
112
- /**
113
- * The uility service to get HTTP status codes.
114
- */
115
- protected readonly _statuses: Statuses;
116
- /**
117
- * @param options The options to construct the service.
118
- */
119
- constructor({ inject: { config, statuses } }: ResponsesBuilderConstructorOptions);
120
- /**
121
- * Generates and send an HTML response that emits a post message.
122
- * The post message will be prefixed with the value of the configuration setting
123
- * `postMessagesPrefix`.
124
- *
125
- * @param options The options to customize how the HTML is generated.
126
- */
127
- htmlPostMessage(options: HTMLPostMessageResponseOptions): void;
128
- /**
129
- * Generates and sends a JSON response.
130
- *
131
- * @param options The options to customize how the JSON is generated.
132
- * @example
133
- *
134
- * <caption>The generated looks like this.</caption>
135
- *
136
- * {
137
- * metadata: {
138
- * version: 'dev',
139
- * status: 200,
140
- * },
141
- * data: { foo: 'bar' },
142
- * }
143
- *
144
- */
145
- json(options: JSONResponseOptions): void;
146
- /**
147
- * Generates a basic HTML template for the service to use when generating a post message
148
- * response.
149
- *
150
- * @param title The HTML `<title />` attribute.
151
- * @param code Javascript code to be wrapped on a `<script />` tag.
152
- */
153
- protected _htmlTemplate(title: string, code: string): string;
154
- /**
155
- * Utility method used to make sure a recevied status is a valid status code. If the
156
- * status is a string, the method will try to find the code from the `statuses` package.
157
- *
158
- * @param status The status to normalize.
159
- * @returns If `status` is a string, but there's no valid code, it will return 200.
160
- */
161
- protected _normalizeStatus(status: number | string): number;
162
- }
163
- /**
164
- * The service provider that once registered on the container will set an instance of
165
- * {@link ResponsesBuilder} as the `responsesBuilder` service.
166
- *
167
- * @example
168
- *
169
- * // Register it on the container
170
- * container.register(responsesBuilderProvider);
171
- * // Getting access to the service instance
172
- * const responsesBuilder = container.get<ResponsesBuilder>('responsesBuilder');
173
- *
174
- * @group Providers
175
- * @group Services/ResponsesBuilder
176
- */
177
- declare const responsesBuilderProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
178
-
179
- export { type HTMLPostMessageResponseOptions, type JSONResponseOptions, ResponsesBuilder, type ResponsesBuilderConstructorOptions, responsesBuilderProvider };
@@ -1,33 +0,0 @@
1
- export { commonServicesProvider } from './common/index.mjs';
2
- export { frontendServicesProvider } from './frontend/index.mjs';
3
- export { htmlServicesProvider } from './html/index.mjs';
4
- export { httpServicesProvider } from './http/index.mjs';
5
- export { utilsServicesProvider } from './utils/index.mjs';
6
- export { AppError, AppErrorClass, AppErrorContext, CreateAppErrorFn, appErrorProvider, createAppError } from './common/appError.mjs';
7
- export { CreateHTTPErrorFn, HTTPError, HTTPErrorClass, createHTTPError, httpErrorProvider } from './common/httpError.mjs';
8
- export { SendFile, SendFileGeneratorOptions, SendFileOptions, sendFile, sendFileProvider } from './common/sendFile.mjs';
9
- export { FrontendFs, FrontendFsOptions, frontendFsProvider } from './frontend/frontendFs.mjs';
10
- export { HTMLGenerator, HTMLGeneratorConstructorOptions, HTMLGeneratorOptions, HTMLGeneratorProviderOptions, HTMLGeneratorValuesService, htmlGeneratorProvider } from './html/htmlGenerator.mjs';
11
- export { ErrorResponse } from '@homer0/api-utils';
12
- export { APIClient, APIClientConfig, APIClientConstructorOptions, APIClientProviderOptions, APIClientSettings, EndpointsType, apiClientProvider } from './http/apiClient.mjs';
13
- export { GetCustomHeadersFromRequestOptions, HTTP, HTTPContructorOptions, HTTPFetchBody, HTTPFetchOptions, HTTPOptions, httpProvider } from './http/http.mjs';
14
- export { HTMLPostMessageResponseOptions, JSONResponseOptions, ResponsesBuilder, ResponsesBuilderConstructorOptions, responsesBuilderProvider } from './http/responsesBuilder.mjs';
15
- export { EnsureBearerConstructorOptions, EnsureBearerToken, EnsureBearerTokenErrorOptions, EnsureBearerTokenOptions, EnsureBearerTokenProviderOptions, ensureBearerTokenProvider } from './utils/ensureBearerToken.mjs';
16
- import '@homer0/jimple';
17
- import '../index-Bwf7JHu9.mjs';
18
- import '../types/express.mjs';
19
- import 'express';
20
- import '../types/http.mjs';
21
- import 'https';
22
- import 'http';
23
- import 'spdy';
24
- import 'node-fetch';
25
- import '../types/utils.mjs';
26
- import '@homer0/path-utils';
27
- import '@homer0/simple-logger';
28
- import '@homer0/simple-config';
29
- import '@homer0/events-hub';
30
- import '../utils/fns/statuses.mjs';
31
- import 'statuses';
32
- import 'fs/promises';
33
- import '@homer0/deferred';
@@ -1,158 +0,0 @@
1
- import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
3
- import { ExpressMiddleware } from '../../types/express.mjs';
4
- import { Statuses } from '../../utils/fns/statuses.mjs';
5
- import { DeepPartial } from '../../types/utils.mjs';
6
- import { HTTPErrorClass } from '../common/httpError.mjs';
7
- import '../../types/http.mjs';
8
- import 'https';
9
- import 'http';
10
- import 'spdy';
11
- import 'node-fetch';
12
- import 'express';
13
- import '@homer0/path-utils';
14
- import '@homer0/simple-logger';
15
- import '@homer0/simple-config';
16
- import '@homer0/events-hub';
17
- import 'statuses';
18
- import '../common/appError.mjs';
19
-
20
- /**
21
- * The options for the error the middleare can generate.
22
- *
23
- * @group Services/EnsureBearerToken
24
- */
25
- type EnsureBearerTokenErrorOptions = {
26
- /**
27
- * The error message for the response.
28
- *
29
- * @default 'Unauthorized'
30
- */
31
- message: string;
32
- /**
33
- * The HTTP status that will be added to the error context.
34
- *
35
- * @default 401
36
- */
37
- status: number;
38
- /**
39
- * Context information for the error handler and that can be added to the actual
40
- * response.
41
- */
42
- response: unknown;
43
- };
44
- /**
45
- * The options to customize the service/middleware.
46
- *
47
- * @group Services/EnsureBearerToken
48
- */
49
- type EnsureBearerTokenOptions = {
50
- error: EnsureBearerTokenErrorOptions;
51
- expression: RegExp;
52
- local: string;
53
- };
54
- /**
55
- * The options to construct a {@link EnsureBearerToken}.
56
- *
57
- * @group Services/EnsureBearerToken
58
- */
59
- type EnsureBearerConstructorOptions = DeepPartial<EnsureBearerTokenOptions> & {
60
- /**
61
- * A dictionary with the dependencies to inject.
62
- */
63
- inject: {
64
- HTTPError: HTTPErrorClass;
65
- statuses: Statuses;
66
- };
67
- };
68
- /**
69
- * Custom options for the provider that will register an instance of
70
- * {@link EnsureBearerToken}
71
- * as a service.
72
- *
73
- * @group Services/EnsureBearerToken
74
- */
75
- type EnsureBearerTokenProviderOptions = DeepPartial<EnsureBearerTokenOptions> & {
76
- /**
77
- * The name that will be used to register the service on the container. This is to allow
78
- * multiple "instances" of the service to be created.
79
- *
80
- * @default 'ensureBearerToken'
81
- */
82
- serviceName?: string;
83
- };
84
- /**
85
- * This service gives you a middleware that verifies if a request has an `Authorization`
86
- * header with a bearer token; if it does, the token will be saved on the `res.locals`,
87
- * otherwise, it will generate an error.
88
- *
89
- * This is a "service middleware" to allow certain flexibility: you can have controllers
90
- * where some routes are protected and others are not. For those cases, you get the
91
- * service from the container, and include it only in the routes that need it.
92
- *
93
- * @group Services
94
- * @group Services/EnsureBearerToken
95
- */
96
- declare class EnsureBearerToken {
97
- /**
98
- * To generate the errors when the validation fails.
99
- */
100
- protected readonly _HTTPError: HTTPErrorClass;
101
- /**
102
- * The customization options for the service.
103
- */
104
- protected readonly _options: EnsureBearerTokenOptions;
105
- /**
106
- * @param options The options to construct the class.
107
- */
108
- constructor({ inject: { HTTPError, statuses }, ...options }: EnsureBearerConstructorOptions);
109
- /**
110
- * Generates the middleware that verifies if a request has an `Authorization` header
111
- * with a bearer token.
112
- */
113
- getMiddleware(): ExpressMiddleware;
114
- /**
115
- * The customization options.
116
- */
117
- get options(): Readonly<EnsureBearerTokenOptions>;
118
- }
119
- /**
120
- * Generates a "service middleware" that can be used on route controllers in order to
121
- * validate the presence of a bearer token on the requests authorization header.
122
- *
123
- * The registered service is an instance of {@link EnsureBearerToken}, and it uses the key
124
- * `ensureBearerToken`.
125
- *
126
- * Since it's a "provider creator", when registering it, you can pass custom options.
127
- *
128
- * @example
129
- *
130
- * <caption>Basic usage</caption>
131
- *
132
- * // Register it on the container
133
- * container.register(ensureBearerTokenProvider);
134
- *
135
- * // Let's assume we are in a controller now...
136
- * // Getting access to the middleware.
137
- * const ensureBearerToken = container.get<ExpressMiddleware>('ensureBearerToken');
138
- *
139
- * @example
140
- *
141
- * <caption>Customizing the service</caption>
142
- *
143
- * // Register it on the container
144
- * container.register(
145
- * ensureBearerTokenProvider({
146
- * serviceName: 'ensureBearerTokenCustom',
147
- * error: {
148
- * message: 'Missing token!',
149
- * },
150
- * }),
151
- * );
152
- *
153
- * @group Providers
154
- * @group Services/EnsureBearerToken
155
- */
156
- declare const ensureBearerTokenProvider: _homer0_jimple.ResourceCreator<"provider", "register", (options?: EnsureBearerTokenProviderOptions) => (app: Jimpex) => void, _homer0_jimple.ProviderRegisterFn<Jimpex>>;
157
-
158
- export { type EnsureBearerConstructorOptions, EnsureBearerToken, type EnsureBearerTokenErrorOptions, type EnsureBearerTokenOptions, type EnsureBearerTokenProviderOptions, ensureBearerTokenProvider };
@@ -1,44 +0,0 @@
1
- import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
3
- import { EnsureBearerTokenProviderOptions } from './ensureBearerToken.mjs';
4
- export { EnsureBearerConstructorOptions, EnsureBearerToken, EnsureBearerTokenErrorOptions, EnsureBearerTokenOptions, ensureBearerTokenProvider } from './ensureBearerToken.mjs';
5
- import '../../types/express.mjs';
6
- import 'express';
7
- import '../../types/http.mjs';
8
- import 'https';
9
- import 'http';
10
- import 'spdy';
11
- import 'node-fetch';
12
- import '../../types/utils.mjs';
13
- import '@homer0/path-utils';
14
- import '@homer0/simple-logger';
15
- import '@homer0/simple-config';
16
- import '@homer0/events-hub';
17
- import '../../utils/fns/statuses.mjs';
18
- import 'statuses';
19
- import '../common/httpError.mjs';
20
- import '../common/appError.mjs';
21
-
22
- /**
23
- * Registers all the utility services on the container.
24
- *
25
- * - {@link EnsureBearerToken | ensureBearerToken}
26
- *
27
- * @example
28
- *
29
- * // Register the collection on the container
30
- * container.register(utilsServicesProvider);
31
- * // Getting access to one the services instance
32
- * const ensureBearerToken = container.get<EnsureBearerToken>('ensureBearerToken');
33
- *
34
- * @group Providers
35
- */
36
- declare const utilsServicesProvider: {
37
- ensureBearerTokenProvider: _homer0_jimple.ResourceCreator<"provider", "register", (options?: EnsureBearerTokenProviderOptions) => (app: Jimpex) => void, _homer0_jimple.ProviderRegisterFn<Jimpex>>;
38
- } & Record<string, _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>> & {
39
- provider: true;
40
- } & {
41
- register: _homer0_jimple.ProviderRegisterFn<Jimpex>;
42
- } & Record<string, unknown>;
43
-
44
- export { EnsureBearerTokenProviderOptions, utilsServicesProvider };
@@ -1,14 +0,0 @@
1
- import './express.mjs';
2
- export { E as EventPayload, l as Events, k as JimpexEventListener, b as JimpexEventName, i as JimpexEventNameLike, c as JimpexEventPayload, a as JimpexEvents, f as JimpexReducerEventName, h as JimpexReducerEventPayload, e as JimpexReducerEventPayloads, g as JimpexReducerEventTarget, d as JimpexReducerEventTargets } from '../index-Bwf7JHu9.mjs';
3
- import 'express';
4
- import './http.mjs';
5
- import 'https';
6
- import 'http';
7
- import 'spdy';
8
- import 'node-fetch';
9
- import './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,10 +0,0 @@
1
- import { RequestHandler, ErrorRequestHandler } from 'express';
2
- export { Express, NextFunction, Request, Response, Router } from 'express';
3
-
4
- type ExpressMiddlewareLike = RequestHandler | ErrorRequestHandler;
5
- type ExpressMiddleware = RequestHandler;
6
- type AsyncExpressMiddleware = (...args: Parameters<ExpressMiddleware>) => Promise<void>;
7
- type ExpressErrorHandler = ErrorRequestHandler;
8
- type RouterMethod = 'all' | 'get' | 'head' | 'post' | 'patch' | 'put' | 'delete' | 'connect' | 'options' | 'trace';
9
-
10
- export type { AsyncExpressMiddleware, ExpressErrorHandler, ExpressMiddleware, ExpressMiddlewareLike, RouterMethod };