jimpex 8.0.0 → 10.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 (215) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +2 -2
  3. package/dist/app/index.d.mts +14 -0
  4. package/dist/app/index.d.ts +5 -4
  5. package/dist/app/index.js +4 -0
  6. package/dist/app/jimpex.d.mts +14 -0
  7. package/dist/app/jimpex.d.ts +3 -2
  8. package/dist/app/jimpex.js +238 -2
  9. package/dist/app/jimpex.js.map +1 -1
  10. package/dist/controllers/common/config.d.mts +79 -0
  11. package/dist/controllers/common/config.d.ts +4 -3
  12. package/dist/controllers/common/config.js +18 -0
  13. package/dist/controllers/common/config.js.map +1 -1
  14. package/dist/controllers/common/health.d.mts +83 -0
  15. package/dist/controllers/common/health.d.ts +5 -4
  16. package/dist/controllers/common/health.js +18 -0
  17. package/dist/controllers/common/health.js.map +1 -1
  18. package/dist/controllers/common/index.d.mts +22 -0
  19. package/dist/controllers/common/index.d.ts +5 -4
  20. package/dist/controllers/common/index.js +6 -0
  21. package/dist/controllers/common/statics.d.mts +223 -0
  22. package/dist/controllers/common/statics.d.ts +13 -5
  23. package/dist/controllers/common/statics.js +60 -3
  24. package/dist/controllers/common/statics.js.map +1 -1
  25. package/dist/controllers/index.d.mts +25 -0
  26. package/dist/controllers/index.d.ts +5 -4
  27. package/dist/controllers/index.js +5 -0
  28. package/dist/controllers/utils/gateway.d.mts +725 -0
  29. package/dist/controllers/utils/gateway.d.ts +5 -4
  30. package/dist/controllers/utils/gateway.js +155 -0
  31. package/dist/controllers/utils/gateway.js.map +1 -1
  32. package/dist/controllers/utils/index.d.mts +17 -0
  33. package/dist/controllers/utils/index.d.ts +4 -3
  34. package/dist/controllers/utils/index.js +4 -0
  35. package/dist/esm/app/jimpex.js +235 -3
  36. package/dist/esm/app/jimpex.js.map +1 -1
  37. package/dist/esm/{chunk-T2T6Q22Z.js → chunk-F3FYYIAV.js} +1 -1
  38. package/dist/esm/controllers/common/config.js +19 -1
  39. package/dist/esm/controllers/common/config.js.map +1 -1
  40. package/dist/esm/controllers/common/health.js +19 -1
  41. package/dist/esm/controllers/common/health.js.map +1 -1
  42. package/dist/esm/controllers/common/statics.js +57 -4
  43. package/dist/esm/controllers/common/statics.js.map +1 -1
  44. package/dist/esm/controllers/utils/gateway.js +156 -1
  45. package/dist/esm/controllers/utils/gateway.js.map +1 -1
  46. package/dist/esm/middlewares/common/errorHandler.js +25 -1
  47. package/dist/esm/middlewares/common/errorHandler.js.map +1 -1
  48. package/dist/esm/middlewares/common/forceHTTPS.js +13 -1
  49. package/dist/esm/middlewares/common/forceHTTPS.js.map +1 -1
  50. package/dist/esm/middlewares/common/hsts.js +22 -1
  51. package/dist/esm/middlewares/common/hsts.js.map +1 -1
  52. package/dist/esm/middlewares/html/fastHTML.js +55 -1
  53. package/dist/esm/middlewares/html/fastHTML.js.map +1 -1
  54. package/dist/esm/middlewares/html/showHTML.js +33 -1
  55. package/dist/esm/middlewares/html/showHTML.js.map +1 -1
  56. package/dist/esm/middlewares/utils/versionValidator.js +35 -1
  57. package/dist/esm/middlewares/utils/versionValidator.js.map +1 -1
  58. package/dist/esm/services/common/appError.js +48 -2
  59. package/dist/esm/services/common/appError.js.map +1 -1
  60. package/dist/esm/services/common/httpError.js +10 -1
  61. package/dist/esm/services/common/httpError.js.map +1 -1
  62. package/dist/esm/services/common/index.js +1 -1
  63. package/dist/esm/services/common/sendFile.js +1 -1
  64. package/dist/esm/services/frontend/frontendFs.js +29 -1
  65. package/dist/esm/services/frontend/frontendFs.js.map +1 -1
  66. package/dist/esm/services/frontend/index.js +1 -1
  67. package/dist/esm/services/html/htmlGenerator.js +51 -1
  68. package/dist/esm/services/html/htmlGenerator.js.map +1 -1
  69. package/dist/esm/services/html/index.js +1 -1
  70. package/dist/esm/services/http/apiClient.js +27 -1
  71. package/dist/esm/services/http/apiClient.js.map +1 -1
  72. package/dist/esm/services/http/http.js +60 -5
  73. package/dist/esm/services/http/http.js.map +1 -1
  74. package/dist/esm/services/http/index.js +1 -1
  75. package/dist/esm/services/http/responsesBuilder.js +49 -2
  76. package/dist/esm/services/http/responsesBuilder.js.map +1 -1
  77. package/dist/esm/services/utils/ensureBearerToken.js +17 -1
  78. package/dist/esm/services/utils/ensureBearerToken.js.map +1 -1
  79. package/dist/esm/services/utils/index.js +1 -1
  80. package/dist/esm/utils/fns/others.js +1 -1
  81. package/dist/esm/utils/fns/routes.js +1 -1
  82. package/dist/esm/utils/fns/routes.js.map +1 -1
  83. package/dist/esm/utils/fns/statuses.js +1 -1
  84. package/dist/esm/utils/fns/text.js +1 -1
  85. package/dist/esm/utils/wrappers.js +1 -1
  86. package/dist/index-Bwf7JHu9.d.mts +1287 -0
  87. package/dist/{jimpex-7eaee271.d.ts → index-C6I3NCC-.d.ts} +15 -6
  88. package/dist/index.d.mts +47 -0
  89. package/dist/index.d.ts +3 -2
  90. package/dist/index.js +9 -0
  91. package/dist/middlewares/common/errorHandler.d.mts +132 -0
  92. package/dist/middlewares/common/errorHandler.d.ts +5 -4
  93. package/dist/middlewares/common/errorHandler.js +24 -0
  94. package/dist/middlewares/common/errorHandler.js.map +1 -1
  95. package/dist/middlewares/common/forceHTTPS.d.mts +69 -0
  96. package/dist/middlewares/common/forceHTTPS.d.ts +6 -5
  97. package/dist/middlewares/common/forceHTTPS.js +12 -0
  98. package/dist/middlewares/common/forceHTTPS.js.map +1 -1
  99. package/dist/middlewares/common/hsts.d.mts +110 -0
  100. package/dist/middlewares/common/hsts.d.ts +6 -5
  101. package/dist/middlewares/common/hsts.js +21 -0
  102. package/dist/middlewares/common/hsts.js.map +1 -1
  103. package/dist/middlewares/common/index.d.mts +22 -0
  104. package/dist/middlewares/common/index.d.ts +4 -3
  105. package/dist/middlewares/common/index.js +6 -0
  106. package/dist/middlewares/html/fastHTML.d.mts +180 -0
  107. package/dist/middlewares/html/fastHTML.d.ts +5 -5
  108. package/dist/middlewares/html/fastHTML.js +54 -0
  109. package/dist/middlewares/html/fastHTML.js.map +1 -1
  110. package/dist/middlewares/html/index.d.mts +21 -0
  111. package/dist/middlewares/html/index.d.ts +4 -4
  112. package/dist/middlewares/html/index.js +5 -0
  113. package/dist/middlewares/html/showHTML.d.mts +127 -0
  114. package/dist/middlewares/html/showHTML.d.ts +5 -5
  115. package/dist/middlewares/html/showHTML.js +32 -0
  116. package/dist/middlewares/html/showHTML.js.map +1 -1
  117. package/dist/middlewares/index.d.mts +30 -0
  118. package/dist/middlewares/index.d.ts +4 -4
  119. package/dist/middlewares/index.js +6 -0
  120. package/dist/middlewares/utils/index.d.mts +20 -0
  121. package/dist/middlewares/utils/index.d.ts +4 -3
  122. package/dist/middlewares/utils/index.js +4 -0
  123. package/dist/middlewares/utils/versionValidator.d.mts +215 -0
  124. package/dist/middlewares/utils/versionValidator.d.ts +5 -4
  125. package/dist/middlewares/utils/versionValidator.js +34 -0
  126. package/dist/middlewares/utils/versionValidator.js.map +1 -1
  127. package/dist/services/common/appError.d.mts +139 -0
  128. package/dist/services/common/appError.d.ts +5 -4
  129. package/dist/services/common/appError.js +47 -1
  130. package/dist/services/common/appError.js.map +1 -1
  131. package/dist/services/common/httpError.d.mts +80 -0
  132. package/dist/services/common/httpError.d.ts +5 -4
  133. package/dist/services/common/httpError.js +9 -0
  134. package/dist/services/common/httpError.js.map +1 -1
  135. package/dist/services/common/index.d.mts +47 -0
  136. package/dist/services/common/index.d.ts +4 -4
  137. package/dist/services/common/index.js +4 -1
  138. package/dist/services/common/sendFile.d.mts +102 -0
  139. package/dist/services/common/sendFile.d.ts +4 -4
  140. package/dist/services/frontend/frontendFs.d.mts +96 -0
  141. package/dist/services/frontend/frontendFs.d.ts +4 -4
  142. package/dist/services/frontend/frontendFs.js +32 -0
  143. package/dist/services/frontend/frontendFs.js.map +1 -1
  144. package/dist/services/frontend/index.d.mts +40 -0
  145. package/dist/services/frontend/index.d.ts +4 -4
  146. package/dist/services/frontend/index.js +2 -1
  147. package/dist/services/html/htmlGenerator.d.mts +237 -0
  148. package/dist/services/html/htmlGenerator.d.ts +3 -3
  149. package/dist/services/html/htmlGenerator.js +50 -0
  150. package/dist/services/html/htmlGenerator.js.map +1 -1
  151. package/dist/services/html/index.d.mts +43 -0
  152. package/dist/services/html/index.d.ts +4 -4
  153. package/dist/services/html/index.js +2 -1
  154. package/dist/services/http/apiClient.d.mts +170 -0
  155. package/dist/services/http/apiClient.d.ts +5 -4
  156. package/dist/services/http/apiClient.js +26 -0
  157. package/dist/services/http/apiClient.js.map +1 -1
  158. package/dist/services/http/http.d.mts +182 -0
  159. package/dist/services/http/http.d.ts +15 -8
  160. package/dist/services/http/http.js +63 -4
  161. package/dist/services/http/http.js.map +1 -1
  162. package/dist/services/http/index.d.mts +51 -0
  163. package/dist/services/http/index.d.ts +4 -3
  164. package/dist/services/http/index.js +4 -1
  165. package/dist/services/http/responsesBuilder.d.mts +179 -0
  166. package/dist/services/http/responsesBuilder.d.ts +4 -3
  167. package/dist/services/http/responsesBuilder.js +48 -1
  168. package/dist/services/http/responsesBuilder.js.map +1 -1
  169. package/dist/services/index.d.mts +33 -0
  170. package/dist/services/index.d.ts +4 -4
  171. package/dist/services/index.js +8 -0
  172. package/dist/services/utils/ensureBearerToken.d.mts +158 -0
  173. package/dist/services/utils/ensureBearerToken.d.ts +6 -5
  174. package/dist/services/utils/ensureBearerToken.js +16 -0
  175. package/dist/services/utils/ensureBearerToken.js.map +1 -1
  176. package/dist/services/utils/index.d.mts +44 -0
  177. package/dist/services/utils/index.d.ts +4 -3
  178. package/dist/services/utils/index.js +2 -1
  179. package/dist/types/events.d.mts +14 -0
  180. package/dist/types/events.d.ts +5 -4
  181. package/dist/types/express.d.mts +10 -0
  182. package/dist/types/express.d.ts +1 -1
  183. package/dist/types/http.d.mts +82 -0
  184. package/dist/types/http.d.ts +5 -2
  185. package/dist/types/http.js.map +1 -1
  186. package/dist/types/index.d.mts +14 -0
  187. package/dist/types/index.d.ts +2 -2
  188. package/dist/types/index.js +9 -0
  189. package/dist/types/options.d.mts +14 -0
  190. package/dist/types/options.d.ts +4 -3
  191. package/dist/types/utils.d.mts +48 -0
  192. package/dist/types/utils.d.ts +1 -1
  193. package/dist/types/wootils.d.mts +4 -0
  194. package/dist/utils/fns/index.d.mts +5 -0
  195. package/dist/utils/fns/index.js +7 -0
  196. package/dist/utils/fns/others.d.mts +17 -0
  197. package/dist/utils/fns/routes.d.mts +39 -0
  198. package/dist/utils/fns/routes.js.map +1 -1
  199. package/dist/utils/fns/statuses.d.mts +45 -0
  200. package/dist/utils/fns/statuses.d.ts +1 -1
  201. package/dist/utils/fns/statuses.js +4 -0
  202. package/dist/utils/fns/statuses.js.map +1 -1
  203. package/dist/utils/fns/text.d.mts +9 -0
  204. package/dist/utils/index.d.mts +19 -0
  205. package/dist/utils/index.d.ts +5 -4
  206. package/dist/utils/index.js +5 -0
  207. package/dist/utils/wrappers.d.mts +14 -0
  208. package/dist/utils/wrappers.d.ts +4 -3
  209. package/package.json +50 -49
  210. package/src/app/jimpex.ts +15 -2
  211. package/src/controllers/common/statics.ts +13 -2
  212. package/src/controllers/utils/gateway.ts +4 -0
  213. package/src/services/http/http.ts +13 -4
  214. package/src/types/http.ts +3 -0
  215. /package/dist/esm/{chunk-T2T6Q22Z.js.map → chunk-F3FYYIAV.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/services/utils/ensureBearerToken.ts"],"sourcesContent":["import { deepAssignWithOverwrite } from '@homer0/deep-assign';\nimport { providerCreator, type Statuses } from '../../utils';\nimport type { HTTPErrorClass } from '../common';\nimport type { DeepPartial, ExpressMiddleware } from '../../types';\n/**\n * The options for the error the middleare can generate.\n *\n * @group Services/EnsureBearerToken\n */\nexport type EnsureBearerTokenErrorOptions = {\n /**\n * The error message for the response.\n *\n * @default 'Unauthorized'\n */\n message: string;\n /**\n * The HTTP status that will be added to the error context.\n *\n * @default 401\n */\n status: number;\n /**\n * Context information for the error handler and that can be added to the actual\n * response.\n */\n response: unknown;\n};\n/**\n * The options to customize the service/middleware.\n *\n * @group Services/EnsureBearerToken\n */\nexport type EnsureBearerTokenOptions = {\n error: EnsureBearerTokenErrorOptions;\n expression: RegExp;\n local: string;\n};\n/**\n * The options to construct a {@link EnsureBearerToken}.\n *\n * @group Services/EnsureBearerToken\n */\nexport type EnsureBearerConstructorOptions = DeepPartial<EnsureBearerTokenOptions> & {\n /**\n * A dictionary with the dependencies to inject.\n */\n inject: {\n HTTPError: HTTPErrorClass;\n statuses: Statuses;\n };\n};\n/**\n * Custom options for the provider that will register an instance of\n * {@link EnsureBearerToken}\n * as a service.\n *\n * @group Services/EnsureBearerToken\n */\nexport type EnsureBearerTokenProviderOptions = DeepPartial<EnsureBearerTokenOptions> & {\n /**\n * The name that will be used to register the service on the container. This is to allow\n * multiple \"instances\" of the service to be created.\n *\n * @default 'ensureBearerToken'\n */\n serviceName?: string;\n};\n/**\n * This service gives you a middleware that verifies if a request has an `Authorization`\n * header with a bearer token; if it does, the token will be saved on the `res.locals`,\n * otherwise, it will generate an error.\n *\n * This is a \"service middleware\" to allow certain flexibility: you can have controllers\n * where some routes are protected and others are not. For those cases, you get the\n * service from the container, and include it only in the routes that need it.\n *\n * @group Services\n * @group Services/EnsureBearerToken\n */\nexport class EnsureBearerToken {\n /**\n * To generate the errors when the validation fails.\n */\n protected readonly _HTTPError: HTTPErrorClass;\n /**\n * The customization options for the service.\n */\n protected readonly _options: EnsureBearerTokenOptions;\n /**\n * @param options The options to construct the class.\n */\n constructor({\n inject: { HTTPError, statuses },\n ...options\n }: EnsureBearerConstructorOptions) {\n this._HTTPError = HTTPError;\n this._options = deepAssignWithOverwrite(\n {\n error: {\n message: 'Unauthorized',\n status: statuses('unauthorized'),\n response: {},\n },\n expression: /bearer (.*?)(?:$|\\s)/i,\n local: 'token',\n },\n options,\n );\n }\n /**\n * Generates the middleware that verifies if a request has an `Authorization` header\n * with a bearer token.\n */\n getMiddleware(): ExpressMiddleware {\n return (req, res, next) => {\n let unauthorized = true;\n const {\n headers: { authorization },\n } = req;\n if (authorization) {\n const matches = this._options.expression.exec(authorization);\n if (matches) {\n const [, token] = matches;\n res.locals[this._options.local] = token;\n unauthorized = false;\n }\n }\n\n if (unauthorized) {\n const {\n error: { message, status, response },\n } = this._options;\n next(\n new this._HTTPError(message, status, {\n response,\n }),\n );\n } else {\n next();\n }\n };\n }\n /**\n * The customization options.\n */\n get options(): Readonly<EnsureBearerTokenOptions> {\n return deepAssignWithOverwrite({}, this._options);\n }\n}\n/**\n * Generates a \"service middleware\" that can be used on route controllers in order to\n * validate the presence of a bearer token on the requests authorization header.\n *\n * The registered service is an instance of {@link EnsureBearerToken}, and it uses the key\n * `ensureBearerToken`.\n *\n * Since it's a \"provider creator\", when registering it, you can pass custom options.\n *\n * @example\n *\n * <caption>Basic usage</caption>\n *\n * // Register it on the container\n * container.register(ensureBearerTokenProvider);\n *\n * // Let's assume we are in a controller now...\n * // Getting access to the middleware.\n * const ensureBearerToken = container.get<ExpressMiddleware>('ensureBearerToken');\n *\n * @example\n *\n * <caption>Customizing the service</caption>\n *\n * // Register it on the container\n * container.register(\n * ensureBearerTokenProvider({\n * serviceName: 'ensureBearerTokenCustom',\n * error: {\n * message: 'Missing token!',\n * },\n * }),\n * );\n *\n * @group Providers\n * @group Services/EnsureBearerToken\n */\nexport const ensureBearerTokenProvider = providerCreator(\n (options: EnsureBearerTokenProviderOptions = {}) =>\n (app) => {\n const { serviceName = 'ensureBearerToken', ...rest } = options;\n app.set(serviceName, () =>\n new EnsureBearerToken({\n inject: {\n HTTPError: app.get('HTTPError'),\n statuses: app.get('statuses'),\n },\n ...rest,\n }).getMiddleware(),\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAwC;AACxC,mBAA+C;AA+ExC,MAAM,kBAAkB;AAAA,EAY7B,YAAY;AAAA,IACV,QAAQ,EAAE,WAAW,SAAS;AAAA,OAC3B;AAAA,EACL,GAAmC;AAXnC,wBAAmB;AAInB,wBAAmB;AAQjB,SAAK,aAAa;AAClB,SAAK,eAAW;AAAA,MACd;AAAA,QACE,OAAO;AAAA,UACL,SAAS;AAAA,UACT,QAAQ,SAAS,cAAc;AAAA,UAC/B,UAAU,CAAC;AAAA,QACb;AAAA,QACA,YAAY;AAAA,QACZ,OAAO;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAKA,gBAAmC;AACjC,WAAO,CAAC,KAAK,KAAK,SAAS;AACzB,UAAI,eAAe;AACnB,YAAM;AAAA,QACJ,SAAS,EAAE,cAAc;AAAA,MAC3B,IAAI;AACJ,UAAI,eAAe;AACjB,cAAM,UAAU,KAAK,SAAS,WAAW,KAAK,aAAa;AAC3D,YAAI,SAAS;AACX,gBAAM,CAAC,EAAE,KAAK,IAAI;AAClB,cAAI,OAAO,KAAK,SAAS,SAAS;AAClC,yBAAe;AAAA,QACjB;AAAA,MACF;AAEA,UAAI,cAAc;AAChB,cAAM;AAAA,UACJ,OAAO,EAAE,SAAS,QAAQ,SAAS;AAAA,QACrC,IAAI,KAAK;AACT;AAAA,UACE,IAAI,KAAK,WAAW,SAAS,QAAQ;AAAA,YACnC;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF,OAAO;AACL,aAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AAAA,EAIA,IAAI,UAA8C;AAChD,eAAO,4CAAwB,CAAC,GAAG,KAAK,QAAQ;AAAA,EAClD;AACF;AAsCO,MAAM,gCAA4B;AAAA,EACvC,CAAC,UAA4C,CAAC,MAC5C,CAAC,QAAQ;AACP,UAAM,EAAE,cAAc,wBAAwB,KAAK,IAAI;AACvD,QAAI;AAAA,MAAI;AAAA,MAAa,MACnB,IAAI,kBAAkB;AAAA,QACpB,QAAQ;AAAA,UACN,WAAW,IAAI,IAAI,WAAW;AAAA,UAC9B,UAAU,IAAI,IAAI,UAAU;AAAA,QAC9B;AAAA,QACA,GAAG;AAAA,MACL,CAAC,EAAE,cAAc;AAAA,IACnB;AAAA,EACF;AACJ;","names":[]}
1
+ {"version":3,"sources":["../../../src/services/utils/ensureBearerToken.ts"],"sourcesContent":["import { deepAssignWithOverwrite } from '@homer0/deep-assign';\nimport { providerCreator, type Statuses } from '../../utils';\nimport type { HTTPErrorClass } from '../common';\nimport type { DeepPartial, ExpressMiddleware } from '../../types';\n/**\n * The options for the error the middleare can generate.\n *\n * @group Services/EnsureBearerToken\n */\nexport type EnsureBearerTokenErrorOptions = {\n /**\n * The error message for the response.\n *\n * @default 'Unauthorized'\n */\n message: string;\n /**\n * The HTTP status that will be added to the error context.\n *\n * @default 401\n */\n status: number;\n /**\n * Context information for the error handler and that can be added to the actual\n * response.\n */\n response: unknown;\n};\n/**\n * The options to customize the service/middleware.\n *\n * @group Services/EnsureBearerToken\n */\nexport type EnsureBearerTokenOptions = {\n error: EnsureBearerTokenErrorOptions;\n expression: RegExp;\n local: string;\n};\n/**\n * The options to construct a {@link EnsureBearerToken}.\n *\n * @group Services/EnsureBearerToken\n */\nexport type EnsureBearerConstructorOptions = DeepPartial<EnsureBearerTokenOptions> & {\n /**\n * A dictionary with the dependencies to inject.\n */\n inject: {\n HTTPError: HTTPErrorClass;\n statuses: Statuses;\n };\n};\n/**\n * Custom options for the provider that will register an instance of\n * {@link EnsureBearerToken}\n * as a service.\n *\n * @group Services/EnsureBearerToken\n */\nexport type EnsureBearerTokenProviderOptions = DeepPartial<EnsureBearerTokenOptions> & {\n /**\n * The name that will be used to register the service on the container. This is to allow\n * multiple \"instances\" of the service to be created.\n *\n * @default 'ensureBearerToken'\n */\n serviceName?: string;\n};\n/**\n * This service gives you a middleware that verifies if a request has an `Authorization`\n * header with a bearer token; if it does, the token will be saved on the `res.locals`,\n * otherwise, it will generate an error.\n *\n * This is a \"service middleware\" to allow certain flexibility: you can have controllers\n * where some routes are protected and others are not. For those cases, you get the\n * service from the container, and include it only in the routes that need it.\n *\n * @group Services\n * @group Services/EnsureBearerToken\n */\nexport class EnsureBearerToken {\n /**\n * To generate the errors when the validation fails.\n */\n protected readonly _HTTPError: HTTPErrorClass;\n /**\n * The customization options for the service.\n */\n protected readonly _options: EnsureBearerTokenOptions;\n /**\n * @param options The options to construct the class.\n */\n constructor({\n inject: { HTTPError, statuses },\n ...options\n }: EnsureBearerConstructorOptions) {\n this._HTTPError = HTTPError;\n this._options = deepAssignWithOverwrite(\n {\n error: {\n message: 'Unauthorized',\n status: statuses('unauthorized'),\n response: {},\n },\n expression: /bearer (.*?)(?:$|\\s)/i,\n local: 'token',\n },\n options,\n );\n }\n /**\n * Generates the middleware that verifies if a request has an `Authorization` header\n * with a bearer token.\n */\n getMiddleware(): ExpressMiddleware {\n return (req, res, next) => {\n let unauthorized = true;\n const {\n headers: { authorization },\n } = req;\n if (authorization) {\n const matches = this._options.expression.exec(authorization);\n if (matches) {\n const [, token] = matches;\n res.locals[this._options.local] = token;\n unauthorized = false;\n }\n }\n\n if (unauthorized) {\n const {\n error: { message, status, response },\n } = this._options;\n next(\n new this._HTTPError(message, status, {\n response,\n }),\n );\n } else {\n next();\n }\n };\n }\n /**\n * The customization options.\n */\n get options(): Readonly<EnsureBearerTokenOptions> {\n return deepAssignWithOverwrite({}, this._options);\n }\n}\n/**\n * Generates a \"service middleware\" that can be used on route controllers in order to\n * validate the presence of a bearer token on the requests authorization header.\n *\n * The registered service is an instance of {@link EnsureBearerToken}, and it uses the key\n * `ensureBearerToken`.\n *\n * Since it's a \"provider creator\", when registering it, you can pass custom options.\n *\n * @example\n *\n * <caption>Basic usage</caption>\n *\n * // Register it on the container\n * container.register(ensureBearerTokenProvider);\n *\n * // Let's assume we are in a controller now...\n * // Getting access to the middleware.\n * const ensureBearerToken = container.get<ExpressMiddleware>('ensureBearerToken');\n *\n * @example\n *\n * <caption>Customizing the service</caption>\n *\n * // Register it on the container\n * container.register(\n * ensureBearerTokenProvider({\n * serviceName: 'ensureBearerTokenCustom',\n * error: {\n * message: 'Missing token!',\n * },\n * }),\n * );\n *\n * @group Providers\n * @group Services/EnsureBearerToken\n */\nexport const ensureBearerTokenProvider = providerCreator(\n (options: EnsureBearerTokenProviderOptions = {}) =>\n (app) => {\n const { serviceName = 'ensureBearerToken', ...rest } = options;\n app.set(serviceName, () =>\n new EnsureBearerToken({\n inject: {\n HTTPError: app.get('HTTPError'),\n statuses: app.get('statuses'),\n },\n ...rest,\n }).getMiddleware(),\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAwC;AACxC,mBAA+C;AA+ExC,MAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA,EAY7B,YAAY;AAAA,IACV,QAAQ,EAAE,WAAW,SAAS;AAAA,IAC9B,GAAG;AAAA,EACL,GAAmC;AAXnC;AAAA;AAAA;AAAA,wBAAmB;AAInB;AAAA;AAAA;AAAA,wBAAmB;AAQjB,SAAK,aAAa;AAClB,SAAK,eAAW;AAAA,MACd;AAAA,QACE,OAAO;AAAA,UACL,SAAS;AAAA,UACT,QAAQ,SAAS,cAAc;AAAA,UAC/B,UAAU,CAAC;AAAA,QACb;AAAA,QACA,YAAY;AAAA,QACZ,OAAO;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,gBAAmC;AACjC,WAAO,CAAC,KAAK,KAAK,SAAS;AACzB,UAAI,eAAe;AACnB,YAAM;AAAA,QACJ,SAAS,EAAE,cAAc;AAAA,MAC3B,IAAI;AACJ,UAAI,eAAe;AACjB,cAAM,UAAU,KAAK,SAAS,WAAW,KAAK,aAAa;AAC3D,YAAI,SAAS;AACX,gBAAM,CAAC,EAAE,KAAK,IAAI;AAClB,cAAI,OAAO,KAAK,SAAS,KAAK,IAAI;AAClC,yBAAe;AAAA,QACjB;AAAA,MACF;AAEA,UAAI,cAAc;AAChB,cAAM;AAAA,UACJ,OAAO,EAAE,SAAS,QAAQ,SAAS;AAAA,QACrC,IAAI,KAAK;AACT;AAAA,UACE,IAAI,KAAK,WAAW,SAAS,QAAQ;AAAA,YACnC;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF,OAAO;AACL,aAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,UAA8C;AAChD,eAAO,4CAAwB,CAAC,GAAG,KAAK,QAAQ;AAAA,EAClD;AACF;AAsCO,MAAM,gCAA4B;AAAA,EACvC,CAAC,UAA4C,CAAC,MAC5C,CAAC,QAAQ;AACP,UAAM,EAAE,cAAc,qBAAqB,GAAG,KAAK,IAAI;AACvD,QAAI;AAAA,MAAI;AAAA,MAAa,MACnB,IAAI,kBAAkB;AAAA,QACpB,QAAQ;AAAA,UACN,WAAW,IAAI,IAAI,WAAW;AAAA,UAC9B,UAAU,IAAI,IAAI,UAAU;AAAA,QAC9B;AAAA,QACA,GAAG;AAAA,MACL,CAAC,EAAE,cAAc;AAAA,IACnB;AAAA,EACF;AACJ;","names":[]}
@@ -0,0 +1,44 @@
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,8 +1,7 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../jimpex-7eaee271.js';
2
+ import { J as Jimpex } from '../../index-C6I3NCC-.js';
3
3
  import { EnsureBearerTokenProviderOptions } from './ensureBearerToken.js';
4
4
  export { EnsureBearerConstructorOptions, EnsureBearerToken, EnsureBearerTokenErrorOptions, EnsureBearerTokenOptions, ensureBearerTokenProvider } from './ensureBearerToken.js';
5
- import '@homer0/events-hub';
6
5
  import '../../types/express.js';
7
6
  import 'express';
8
7
  import '../../types/http.js';
@@ -10,9 +9,11 @@ import 'https';
10
9
  import 'http';
11
10
  import 'spdy';
12
11
  import 'node-fetch';
13
- import '@homer0/simple-config';
14
12
  import '../../types/utils.js';
13
+ import '@homer0/path-utils';
15
14
  import '@homer0/simple-logger';
15
+ import '@homer0/simple-config';
16
+ import '@homer0/events-hub';
16
17
  import '../../utils/fns/statuses.js';
17
18
  import 'statuses';
18
19
  import '../common/httpError.js';
@@ -30,6 +30,7 @@ const utilsServicesProvider = (0, import_utils.providers)({
30
30
  });
31
31
  // Annotate the CommonJS export names for ESM import in node:
32
32
  0 && (module.exports = {
33
- utilsServicesProvider
33
+ utilsServicesProvider,
34
+ ...require("./ensureBearerToken")
34
35
  });
35
36
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,14 @@
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,13 +1,14 @@
1
1
  import './express.js';
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 '../jimpex-7eaee271.js';
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-C6I3NCC-.js';
3
3
  import 'express';
4
- import '@homer0/jimple';
5
- import '@homer0/events-hub';
6
4
  import './http.js';
7
5
  import 'https';
8
6
  import 'http';
9
7
  import 'spdy';
10
8
  import 'node-fetch';
11
- import '@homer0/simple-config';
12
9
  import './utils.js';
10
+ import '@homer0/path-utils';
13
11
  import '@homer0/simple-logger';
12
+ import '@homer0/simple-config';
13
+ import '@homer0/events-hub';
14
+ import '@homer0/jimple';
@@ -0,0 +1,10 @@
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 };
@@ -7,4 +7,4 @@ type AsyncExpressMiddleware = (...args: Parameters<ExpressMiddleware>) => Promis
7
7
  type ExpressErrorHandler = ErrorRequestHandler;
8
8
  type RouterMethod = 'all' | 'get' | 'head' | 'post' | 'patch' | 'put' | 'delete' | 'connect' | 'options' | 'trace';
9
9
 
10
- export { AsyncExpressMiddleware, ExpressErrorHandler, ExpressMiddleware, ExpressMiddlewareLike, RouterMethod };
10
+ export type { AsyncExpressMiddleware, ExpressErrorHandler, ExpressMiddleware, ExpressMiddlewareLike, RouterMethod };
@@ -0,0 +1,82 @@
1
+ import { Server } from 'https';
2
+ export { Server as HTTPSServer } from 'https';
3
+ import { Server as Server$1 } from 'http';
4
+ export { Server as HTTPServer } from 'http';
5
+ import { ServerOptions } from 'spdy';
6
+ import NodeFetchFn from 'node-fetch';
7
+ export { Response as HTTPResponse } from 'node-fetch';
8
+ import { Express } from 'express';
9
+
10
+ type NodeFetch = typeof NodeFetchFn;
11
+
12
+ /**
13
+ * @group Jimpex
14
+ */
15
+ type JimpexServer = Express | Server;
16
+ /**
17
+ * @group Jimpex
18
+ */
19
+ type JimpexServerInstance = Server$1 | Server;
20
+ /**
21
+ * The paths to the SSL credentials. Depending on the application options, they can be
22
+ * relative to the project root, or the application executable, but they can't be
23
+ * absolute.
24
+ *
25
+ * @group Jimpex
26
+ */
27
+ type JimpexHTTPSCredentials = {
28
+ /**
29
+ * The path to the certificate authority file.
30
+ */
31
+ ca?: string;
32
+ /**
33
+ * The path to the certificate file.
34
+ */
35
+ cert?: string;
36
+ /**
37
+ * The path to the key file.
38
+ */
39
+ key?: string;
40
+ };
41
+ /**
42
+ * The options to enable HTTP2.
43
+ *
44
+ * @group Jimpex
45
+ */
46
+ type JimpexHTTP2Options = {
47
+ /**
48
+ * Whether or not to enable HTTP2.
49
+ */
50
+ enabled?: boolean;
51
+ /**
52
+ * Custom options for the Spdy server.
53
+ *
54
+ * @see {@link https://github.com/spdy-http2/node-spdy#options}
55
+ */
56
+ spdy?: ServerOptions['spdy'];
57
+ };
58
+ /**
59
+ * The options to enable HTTPS.
60
+ *
61
+ * @group Jimpex
62
+ */
63
+ type JimpexHTTPSOptions = {
64
+ /**
65
+ * Whether or not to enable HTTPS.
66
+ */
67
+ enabled?: boolean;
68
+ /**
69
+ * The SSL credentials, and their location.
70
+ */
71
+ credentials?: JimpexHTTPSCredentials & {
72
+ /**
73
+ * If `true`, the credentials will be located relative to the project root, otherwise,
74
+ * they will be located relative to the application executable.
75
+ *
76
+ * @default false
77
+ */
78
+ onHome?: boolean;
79
+ };
80
+ };
81
+
82
+ export type { JimpexHTTP2Options, JimpexHTTPSCredentials, JimpexHTTPSOptions, JimpexServer, JimpexServerInstance, NodeFetch };
@@ -3,8 +3,11 @@ export { Server as HTTPSServer } from 'https';
3
3
  import { Server as Server$1 } from 'http';
4
4
  export { Server as HTTPServer } from 'http';
5
5
  import { ServerOptions } from 'spdy';
6
- import { Express } from 'express';
6
+ import NodeFetchFn from 'node-fetch';
7
7
  export { Response as HTTPResponse } from 'node-fetch';
8
+ import { Express } from 'express';
9
+
10
+ type NodeFetch = typeof NodeFetchFn;
8
11
 
9
12
  /**
10
13
  * @group Jimpex
@@ -76,4 +79,4 @@ type JimpexHTTPSOptions = {
76
79
  };
77
80
  };
78
81
 
79
- export { JimpexHTTP2Options, JimpexHTTPSCredentials, JimpexHTTPSOptions, JimpexServer, JimpexServerInstance };
82
+ export type { JimpexHTTP2Options, JimpexHTTPSCredentials, JimpexHTTPSOptions, JimpexServer, JimpexServerInstance, NodeFetch };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/http.ts"],"sourcesContent":["import type { Server as HTTPSServer } from 'https';\nimport type { Server as HTTPServer } from 'http';\nimport type { ServerOptions as SpdyServerOptions } from 'spdy';\nimport type { Express } from './express';\n\nexport type { Response as HTTPResponse } from 'node-fetch';\n\nexport type { HTTPSServer, HTTPServer };\n/**\n * @group Jimpex\n */\nexport type JimpexServer = Express | HTTPSServer;\n/**\n * @group Jimpex\n */\nexport type JimpexServerInstance = HTTPServer | HTTPSServer;\n/**\n * The paths to the SSL credentials. Depending on the application options, they can be\n * relative to the project root, or the application executable, but they can't be\n * absolute.\n *\n * @group Jimpex\n */\nexport type JimpexHTTPSCredentials = {\n /**\n * The path to the certificate authority file.\n */\n ca?: string;\n /**\n * The path to the certificate file.\n */\n cert?: string;\n /**\n * The path to the key file.\n */\n key?: string;\n};\n/**\n * The options to enable HTTP2.\n *\n * @group Jimpex\n */\nexport type JimpexHTTP2Options = {\n /**\n * Whether or not to enable HTTP2.\n */\n enabled?: boolean;\n /**\n * Custom options for the Spdy server.\n *\n * @see {@link https://github.com/spdy-http2/node-spdy#options}\n */\n spdy?: SpdyServerOptions['spdy'];\n};\n/**\n * The options to enable HTTPS.\n *\n * @group Jimpex\n */\nexport type JimpexHTTPSOptions = {\n /**\n * Whether or not to enable HTTPS.\n */\n enabled?: boolean;\n /**\n * The SSL credentials, and their location.\n */\n credentials?: JimpexHTTPSCredentials & {\n /**\n * If `true`, the credentials will be located relative to the project root, otherwise,\n * they will be located relative to the application executable.\n *\n * @default false\n */\n onHome?: boolean;\n };\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/http.ts"],"sourcesContent":["import type { Server as HTTPSServer } from 'https';\nimport type { Server as HTTPServer } from 'http';\nimport type { ServerOptions as SpdyServerOptions } from 'spdy';\nimport type NodeFetchFn from 'node-fetch';\nimport type { Express } from './express';\n\nexport type { Response as HTTPResponse } from 'node-fetch';\n\nexport type NodeFetch = typeof NodeFetchFn;\n\nexport type { HTTPSServer, HTTPServer };\n/**\n * @group Jimpex\n */\nexport type JimpexServer = Express | HTTPSServer;\n/**\n * @group Jimpex\n */\nexport type JimpexServerInstance = HTTPServer | HTTPSServer;\n/**\n * The paths to the SSL credentials. Depending on the application options, they can be\n * relative to the project root, or the application executable, but they can't be\n * absolute.\n *\n * @group Jimpex\n */\nexport type JimpexHTTPSCredentials = {\n /**\n * The path to the certificate authority file.\n */\n ca?: string;\n /**\n * The path to the certificate file.\n */\n cert?: string;\n /**\n * The path to the key file.\n */\n key?: string;\n};\n/**\n * The options to enable HTTP2.\n *\n * @group Jimpex\n */\nexport type JimpexHTTP2Options = {\n /**\n * Whether or not to enable HTTP2.\n */\n enabled?: boolean;\n /**\n * Custom options for the Spdy server.\n *\n * @see {@link https://github.com/spdy-http2/node-spdy#options}\n */\n spdy?: SpdyServerOptions['spdy'];\n};\n/**\n * The options to enable HTTPS.\n *\n * @group Jimpex\n */\nexport type JimpexHTTPSOptions = {\n /**\n * Whether or not to enable HTTPS.\n */\n enabled?: boolean;\n /**\n * The SSL credentials, and their location.\n */\n credentials?: JimpexHTTPSCredentials & {\n /**\n * If `true`, the credentials will be located relative to the project root, otherwise,\n * they will be located relative to the application executable.\n *\n * @default false\n */\n onHome?: boolean;\n };\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,14 @@
1
+ export { E as EventPayload, l as Events, m as JimpexConfigOptions, k as JimpexEventListener, b as JimpexEventName, i as JimpexEventNameLike, c as JimpexEventPayload, a as JimpexEvents, o as JimpexExpressOptions, s as JimpexHealthCheckFn, r as JimpexHealthStatus, t as JimpexOptions, p as JimpexPathOptions, f as JimpexReducerEventName, h as JimpexReducerEventPayload, e as JimpexReducerEventPayloads, g as JimpexReducerEventTarget, d as JimpexReducerEventTargets, q as JimpexServicesOptions, u as JimpexStartCallback, n as JimpexStaticsOptions } from '../index-Bwf7JHu9.mjs';
2
+ export { AsyncExpressMiddleware, ExpressErrorHandler, ExpressMiddleware, ExpressMiddlewareLike, RouterMethod } from './express.mjs';
3
+ export { JimpexHTTP2Options, JimpexHTTPSCredentials, JimpexHTTPSOptions, JimpexServer, JimpexServerInstance, NodeFetch } from './http.mjs';
4
+ export { DeepPartial, DeepReadonly, Dict, NoStringIndex } from './utils.mjs';
5
+ export { PathUtils } from '@homer0/path-utils';
6
+ export { SimpleLogger as Logger } from '@homer0/simple-logger';
7
+ export { SimpleConfig as Config } from '@homer0/simple-config';
8
+ export { EventsHub } from '@homer0/events-hub';
9
+ export { Express, NextFunction, Request, Response, Router } from 'express';
10
+ export { Response as HTTPResponse } from 'node-fetch';
11
+ export { Server as HTTPSServer } from 'https';
12
+ export { Server as HTTPServer } from 'http';
13
+ import '@homer0/jimple';
14
+ import 'spdy';
@@ -1,6 +1,6 @@
1
- export { E as EventPayload, l as Events, m as JimpexConfigOptions, k as JimpexEventListener, b as JimpexEventName, i as JimpexEventNameLike, c as JimpexEventPayload, a as JimpexEvents, o as JimpexExpressOptions, s as JimpexHealthCheckFn, r as JimpexHealthStatus, t as JimpexOptions, p as JimpexPathOptions, f as JimpexReducerEventName, h as JimpexReducerEventPayload, e as JimpexReducerEventPayloads, g as JimpexReducerEventTarget, d as JimpexReducerEventTargets, q as JimpexServicesOptions, u as JimpexStartCallback, n as JimpexStaticsOptions } from '../jimpex-7eaee271.js';
1
+ export { E as EventPayload, l as Events, m as JimpexConfigOptions, k as JimpexEventListener, b as JimpexEventName, i as JimpexEventNameLike, c as JimpexEventPayload, a as JimpexEvents, o as JimpexExpressOptions, s as JimpexHealthCheckFn, r as JimpexHealthStatus, t as JimpexOptions, p as JimpexPathOptions, f as JimpexReducerEventName, h as JimpexReducerEventPayload, e as JimpexReducerEventPayloads, g as JimpexReducerEventTarget, d as JimpexReducerEventTargets, q as JimpexServicesOptions, u as JimpexStartCallback, n as JimpexStaticsOptions } from '../index-C6I3NCC-.js';
2
2
  export { AsyncExpressMiddleware, ExpressErrorHandler, ExpressMiddleware, ExpressMiddlewareLike, RouterMethod } from './express.js';
3
- export { JimpexHTTP2Options, JimpexHTTPSCredentials, JimpexHTTPSOptions, JimpexServer, JimpexServerInstance } from './http.js';
3
+ export { JimpexHTTP2Options, JimpexHTTPSCredentials, JimpexHTTPSOptions, JimpexServer, JimpexServerInstance, NodeFetch } from './http.js';
4
4
  export { DeepPartial, DeepReadonly, Dict, NoStringIndex } from './utils.js';
5
5
  export { PathUtils } from '@homer0/path-utils';
6
6
  export { SimpleLogger as Logger } from '@homer0/simple-logger';
@@ -21,4 +21,13 @@ __reExport(types_exports, require("./http"), module.exports);
21
21
  __reExport(types_exports, require("./options"), module.exports);
22
22
  __reExport(types_exports, require("./utils"), module.exports);
23
23
  __reExport(types_exports, require("./wootils"), module.exports);
24
+ // Annotate the CommonJS export names for ESM import in node:
25
+ 0 && (module.exports = {
26
+ ...require("./events"),
27
+ ...require("./express"),
28
+ ...require("./http"),
29
+ ...require("./options"),
30
+ ...require("./utils"),
31
+ ...require("./wootils")
32
+ });
24
33
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,14 @@
1
+ import '@homer0/simple-config';
2
+ export { m as JimpexConfigOptions, o as JimpexExpressOptions, s as JimpexHealthCheckFn, r as JimpexHealthStatus, t as JimpexOptions, p as JimpexPathOptions, q as JimpexServicesOptions, u as JimpexStartCallback, n as JimpexStaticsOptions } from '../index-Bwf7JHu9.mjs';
3
+ import './express.mjs';
4
+ import 'express';
5
+ import './http.mjs';
6
+ import 'https';
7
+ import 'http';
8
+ import 'spdy';
9
+ import 'node-fetch';
10
+ import './utils.mjs';
11
+ import '@homer0/path-utils';
12
+ import '@homer0/simple-logger';
13
+ import '@homer0/events-hub';
14
+ import '@homer0/jimple';
@@ -1,7 +1,5 @@
1
1
  import '@homer0/simple-config';
2
- export { m as JimpexConfigOptions, o as JimpexExpressOptions, s as JimpexHealthCheckFn, r as JimpexHealthStatus, t as JimpexOptions, p as JimpexPathOptions, q as JimpexServicesOptions, u as JimpexStartCallback, n as JimpexStaticsOptions } from '../jimpex-7eaee271.js';
3
- import '@homer0/jimple';
4
- import '@homer0/events-hub';
2
+ export { m as JimpexConfigOptions, o as JimpexExpressOptions, s as JimpexHealthCheckFn, r as JimpexHealthStatus, t as JimpexOptions, p as JimpexPathOptions, q as JimpexServicesOptions, u as JimpexStartCallback, n as JimpexStaticsOptions } from '../index-C6I3NCC-.js';
5
3
  import './express.js';
6
4
  import 'express';
7
5
  import './http.js';
@@ -10,4 +8,7 @@ import 'http';
10
8
  import 'spdy';
11
9
  import 'node-fetch';
12
10
  import './utils.js';
11
+ import '@homer0/path-utils';
13
12
  import '@homer0/simple-logger';
13
+ import '@homer0/events-hub';
14
+ import '@homer0/jimple';
@@ -0,0 +1,48 @@
1
+ /**
2
+ * A simple dictionary with unknown values.
3
+ *
4
+ * @group Utilities
5
+ */
6
+ type Dict = Record<string, unknown>;
7
+ /**
8
+ * Utility to make a deep "partial" of an existing type.
9
+ *
10
+ * @template T The type to make a partial of.
11
+ * @group Utilities
12
+ */
13
+ type DeepPartial<T> = {
14
+ [P in keyof T]?: T[P] extends (infer U)[] ? DeepPartial<U>[] : T[P] extends object ? DeepPartial<T[P]> : T[P];
15
+ };
16
+ /**
17
+ * Utility to make a deep "readonly" of an existing type.
18
+ *
19
+ * @template T The type to make a readonly of.
20
+ * @group Utilities
21
+ */
22
+ type DeepReadonly<T> = {
23
+ readonly [P in keyof T]: T[P] extends (infer U)[] ? DeepReadonly<U>[] : T[P] extends object ? DeepReadonly<T[P]> : T[P];
24
+ };
25
+ /**
26
+ * Utility to remove string indexes from types.
27
+ *
28
+ * @template T The type to remove string indexes from.
29
+ * @example
30
+ *
31
+ * type Foo = {
32
+ * a: string;
33
+ * b: string;
34
+ * [key: string]: string;
35
+ * };
36
+ * type Bar = RemoveStringIndexes<Foo>;
37
+ * // Bar = {
38
+ * // a: string;
39
+ * // b: string;
40
+ * // };
41
+ *
42
+ * @group Utilities
43
+ */
44
+ type NoStringIndex<T> = {
45
+ [K in keyof T as string extends K ? never : K]: T[K];
46
+ };
47
+
48
+ export type { DeepPartial, DeepReadonly, Dict, NoStringIndex };
@@ -45,4 +45,4 @@ type NoStringIndex<T> = {
45
45
  [K in keyof T as string extends K ? never : K]: T[K];
46
46
  };
47
47
 
48
- export { DeepPartial, DeepReadonly, Dict, NoStringIndex };
48
+ export type { DeepPartial, DeepReadonly, Dict, NoStringIndex };
@@ -0,0 +1,4 @@
1
+ export { PathUtils } from '@homer0/path-utils';
2
+ export { SimpleLogger as Logger } from '@homer0/simple-logger';
3
+ export { SimpleConfig as Config } from '@homer0/simple-config';
4
+ export { EventsHub } from '@homer0/events-hub';
@@ -0,0 +1,5 @@
1
+ export { notUndefined } from './others.mjs';
2
+ export { createRouteExpression, removeLeadingSlash, removeSlashes, removeTrailingSlash } from './routes.mjs';
3
+ export { Statuses } from './statuses.mjs';
4
+ export { escapeForRegExp } from './text.mjs';
5
+ export { default as statuses } from 'statuses';
@@ -19,4 +19,11 @@ __reExport(fns_exports, require("./others"), module.exports);
19
19
  __reExport(fns_exports, require("./routes"), module.exports);
20
20
  __reExport(fns_exports, require("./statuses"), module.exports);
21
21
  __reExport(fns_exports, require("./text"), module.exports);
22
+ // Annotate the CommonJS export names for ESM import in node:
23
+ 0 && (module.exports = {
24
+ ...require("./others"),
25
+ ...require("./routes"),
26
+ ...require("./statuses"),
27
+ ...require("./text")
28
+ });
22
29
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,17 @@
1
+ /**
2
+ * A utility function that can be used in `.filter` calls to remove `undefined` values and
3
+ * assert that the type is not longer `undefined`.
4
+ *
5
+ * @param value The value to check.
6
+ * @template T The type that is not `undefined`.
7
+ * @example
8
+ *
9
+ * const arr: (number | undefined)[] = [1, 2, 3, undefined];
10
+ * const filtered = arr.filter(notUndefined);
11
+ * // filtered = [1, 2, 3] and its type is number[]
12
+ *
13
+ * @group Utilities
14
+ */
15
+ declare const notUndefined: <T>(value: T | undefined) => value is T;
16
+
17
+ export { notUndefined };
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Removes any leading slash from a URL.
3
+ *
4
+ * @param url The URL to format.
5
+ * @group Utilities
6
+ */
7
+ declare const removeLeadingSlash: (url: string) => string;
8
+ /**
9
+ * Removes any trailing slash from a URL.
10
+ *
11
+ * @param url The URL to format.
12
+ * @group Utilities
13
+ */
14
+ declare const removeTrailingSlash: (url: string) => string;
15
+ /**
16
+ * Remove any leading and trailing slash from a URL.
17
+ *
18
+ * @param url The URL to format.
19
+ * @param leading Whether or not to remove any leading slash.
20
+ * @param trailing Whether or not to remove the trailing slash.
21
+ * @group Utilities
22
+ */
23
+ declare const removeSlashes: (url: string, leading?: boolean, trailing?: boolean) => string;
24
+ /**
25
+ * Given a server route definition, this function creates a regular expression to match
26
+ * it: The expression replaces the routes parameters with placeholders so it can be
27
+ * compared with real routes.
28
+ *
29
+ * @param route The route from which the expression will be created.
30
+ * @param leadingSlash Whether or not the expression should match a leading slash.
31
+ * @param trailingSlash Whether or not the expression should match a trailing slash.
32
+ * The reason this is `false` by default is because these
33
+ * expressions are often used to match against incoming requests,
34
+ * and they don't have a trailing slash.
35
+ * @group Utilities
36
+ */
37
+ declare const createRouteExpression: (route: string, leadingSlash?: boolean, trailingSlash?: boolean) => RegExp;
38
+
39
+ export { createRouteExpression, removeLeadingSlash, removeSlashes, removeTrailingSlash };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/fns/routes.ts"],"sourcesContent":["import { escapeForRegExp } from './text';\n\n/**\n * Removes any leading slash from a URL.\n *\n * @param url The URL to format.\n * @group Utilities\n */\nexport const removeLeadingSlash = (url: string): string => url.replace(/^\\/+/, '');\n/**\n * Removes any trailing slash from a URL.\n *\n * @param url The URL to format.\n * @group Utilities\n */\nexport const removeTrailingSlash = (url: string): string => url.replace(/\\/+$/, '');\n/**\n * Remove any leading and trailing slash from a URL.\n *\n * @param url The URL to format.\n * @param leading Whether or not to remove any leading slash.\n * @param trailing Whether or not to remove the trailing slash.\n * @group Utilities\n */\nexport const removeSlashes = (\n url: string,\n leading: boolean = true,\n trailing: boolean = true,\n) => {\n const newUrl = leading ? removeLeadingSlash(url) : url;\n return trailing ? removeTrailingSlash(newUrl) : newUrl;\n};\n\n/**\n * Given a server route definition, this function creates a regular expression to match\n * it: The expression replaces the routes parameters with placeholders so it can be\n * compared with real routes.\n *\n * @param route The route from which the expression will be created.\n * @param leadingSlash Whether or not the expression should match a leading slash.\n * @param trailingSlash Whether or not the expression should match a trailing slash.\n * The reason this is `false` by default is because these\n * expressions are often used to match against incoming requests,\n * and they don't have a trailing slash.\n * @group Utilities\n */\nexport const createRouteExpression = (\n route: string,\n leadingSlash: boolean = true,\n trailingSlash: boolean = false,\n): RegExp => {\n let expression = removeSlashes(route)\n .split('/')\n .map((part) => (part.startsWith(':') ? '(?:([^\\\\/]+?))' : escapeForRegExp(part)))\n .join('\\\\/');\n if (leadingSlash) {\n expression = `\\\\/${expression}`;\n }\n if (trailingSlash) {\n expression = `${expression}\\\\/`;\n }\n\n return new RegExp(expression);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAgC;AAQzB,MAAM,qBAAqB,CAAC,QAAwB,IAAI,QAAQ,QAAQ,EAAE;AAO1E,MAAM,sBAAsB,CAAC,QAAwB,IAAI,QAAQ,QAAQ,EAAE;AAS3E,MAAM,gBAAgB,CAC3B,KACA,UAAmB,MACnB,WAAoB,SACjB;AACH,QAAM,SAAS,UAAU,mBAAmB,GAAG,IAAI;AACnD,SAAO,WAAW,oBAAoB,MAAM,IAAI;AAClD;AAeO,MAAM,wBAAwB,CACnC,OACA,eAAwB,MACxB,gBAAyB,UACd;AACX,MAAI,aAAa,cAAc,KAAK,EACjC,MAAM,GAAG,EACT,IAAI,CAAC,SAAU,KAAK,WAAW,GAAG,IAAI,uBAAmB,6BAAgB,IAAI,CAAE,EAC/E,KAAK,KAAK;AACb,MAAI,cAAc;AAChB,iBAAa,MAAM;AAAA,EACrB;AACA,MAAI,eAAe;AACjB,iBAAa,GAAG;AAAA,EAClB;AAEA,SAAO,IAAI,OAAO,UAAU;AAC9B;","names":[]}
1
+ {"version":3,"sources":["../../../src/utils/fns/routes.ts"],"sourcesContent":["import { escapeForRegExp } from './text';\n\n/**\n * Removes any leading slash from a URL.\n *\n * @param url The URL to format.\n * @group Utilities\n */\nexport const removeLeadingSlash = (url: string): string => url.replace(/^\\/+/, '');\n/**\n * Removes any trailing slash from a URL.\n *\n * @param url The URL to format.\n * @group Utilities\n */\nexport const removeTrailingSlash = (url: string): string => url.replace(/\\/+$/, '');\n/**\n * Remove any leading and trailing slash from a URL.\n *\n * @param url The URL to format.\n * @param leading Whether or not to remove any leading slash.\n * @param trailing Whether or not to remove the trailing slash.\n * @group Utilities\n */\nexport const removeSlashes = (\n url: string,\n leading: boolean = true,\n trailing: boolean = true,\n) => {\n const newUrl = leading ? removeLeadingSlash(url) : url;\n return trailing ? removeTrailingSlash(newUrl) : newUrl;\n};\n\n/**\n * Given a server route definition, this function creates a regular expression to match\n * it: The expression replaces the routes parameters with placeholders so it can be\n * compared with real routes.\n *\n * @param route The route from which the expression will be created.\n * @param leadingSlash Whether or not the expression should match a leading slash.\n * @param trailingSlash Whether or not the expression should match a trailing slash.\n * The reason this is `false` by default is because these\n * expressions are often used to match against incoming requests,\n * and they don't have a trailing slash.\n * @group Utilities\n */\nexport const createRouteExpression = (\n route: string,\n leadingSlash: boolean = true,\n trailingSlash: boolean = false,\n): RegExp => {\n let expression = removeSlashes(route)\n .split('/')\n .map((part) => (part.startsWith(':') ? '(?:([^\\\\/]+?))' : escapeForRegExp(part)))\n .join('\\\\/');\n if (leadingSlash) {\n expression = `\\\\/${expression}`;\n }\n if (trailingSlash) {\n expression = `${expression}\\\\/`;\n }\n\n return new RegExp(expression);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAgC;AAQzB,MAAM,qBAAqB,CAAC,QAAwB,IAAI,QAAQ,QAAQ,EAAE;AAO1E,MAAM,sBAAsB,CAAC,QAAwB,IAAI,QAAQ,QAAQ,EAAE;AAS3E,MAAM,gBAAgB,CAC3B,KACA,UAAmB,MACnB,WAAoB,SACjB;AACH,QAAM,SAAS,UAAU,mBAAmB,GAAG,IAAI;AACnD,SAAO,WAAW,oBAAoB,MAAM,IAAI;AAClD;AAeO,MAAM,wBAAwB,CACnC,OACA,eAAwB,MACxB,gBAAyB,UACd;AACX,MAAI,aAAa,cAAc,KAAK,EACjC,MAAM,GAAG,EACT,IAAI,CAAC,SAAU,KAAK,WAAW,GAAG,IAAI,uBAAmB,6BAAgB,IAAI,CAAE,EAC/E,KAAK,KAAK;AACb,MAAI,cAAc;AAChB,iBAAa,MAAM,UAAU;AAAA,EAC/B;AACA,MAAI,eAAe;AACjB,iBAAa,GAAG,UAAU;AAAA,EAC5B;AAEA,SAAO,IAAI,OAAO,UAAU;AAC9B;","names":[]}
@@ -0,0 +1,45 @@
1
+ export { default as statuses } from 'statuses';
2
+
3
+ /**
4
+ * The type definitions for the `statuses` library.
5
+ *
6
+ * While the library has type definitions, TypeScript throws an error that they can't be
7
+ * exported, so that's why they are copied in there.
8
+ */
9
+ type Statuses = {
10
+ /**
11
+ * Given a status code, returns the status text, and given a status text, returns the
12
+ * status code.
13
+ *
14
+ * @param code The status code or status text to look up.
15
+ * @throws If the status is invalid.
16
+ */
17
+ (code: number | string): number | string;
18
+ /**
19
+ * A list of all the supported status codes.
20
+ */
21
+ codes: number[];
22
+ /**
23
+ * A dictionary with the status texts and their corresponding status codes.
24
+ */
25
+ code: Record<string, number | undefined>;
26
+ /**
27
+ * A dictionary with the status codes and their corresponding status texts, for
28
+ * responses that expect an empty body.
29
+ */
30
+ empty: Record<number, boolean | undefined>;
31
+ /**
32
+ * A dictionary with the status codes and their corresponding status texts.
33
+ */
34
+ message: Record<number, string | undefined>;
35
+ /**
36
+ * A dictionary with status codes for responses that are valid for redirections.
37
+ */
38
+ redirect: Record<number, boolean | undefined>;
39
+ /**
40
+ * A dictionary with status codes that should be retried.
41
+ */
42
+ retry: Record<number, boolean | undefined>;
43
+ };
44
+
45
+ export type { Statuses };
@@ -42,4 +42,4 @@ type Statuses = {
42
42
  retry: Record<number, boolean | undefined>;
43
43
  };
44
44
 
45
- export { Statuses };
45
+ export type { Statuses };
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
18
18
  return to;
19
19
  };
20
20
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
25
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
26
  mod
23
27
  ));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/fns/statuses.ts"],"sourcesContent":["import statuses from 'statuses';\n/**\n * The type definitions for the `statuses` library.\n *\n * While the library has type definitions, TypeScript throws an error that they can't be\n * exported, so that's why they are copied in there.\n */\nexport type Statuses = {\n /**\n * Given a status code, returns the status text, and given a status text, returns the\n * status code.\n *\n * @param code The status code or status text to look up.\n * @throws If the status is invalid.\n */\n (code: number | string): number | string;\n /**\n * A list of all the supported status codes.\n */\n codes: number[];\n /**\n * A dictionary with the status texts and their corresponding status codes.\n */\n code: Record<string, number | undefined>;\n /**\n * A dictionary with the status codes and their corresponding status texts, for\n * responses that expect an empty body.\n */\n empty: Record<number, boolean | undefined>;\n /**\n * A dictionary with the status codes and their corresponding status texts.\n */\n message: Record<number, string | undefined>;\n /**\n * A dictionary with status codes for responses that are valid for redirections.\n */\n redirect: Record<number, boolean | undefined>;\n /**\n * A dictionary with status codes that should be retried.\n */\n retry: Record<number, boolean | undefined>;\n};\n\nexport { statuses };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,kCAAAA;AAAA;AAAA;AAAA,sBAAqB;","names":["statuses"]}
1
+ {"version":3,"sources":["../../../src/utils/fns/statuses.ts"],"sourcesContent":["import statuses from 'statuses';\n/**\n * The type definitions for the `statuses` library.\n *\n * While the library has type definitions, TypeScript throws an error that they can't be\n * exported, so that's why they are copied in there.\n */\nexport type Statuses = {\n /**\n * Given a status code, returns the status text, and given a status text, returns the\n * status code.\n *\n * @param code The status code or status text to look up.\n * @throws If the status is invalid.\n */\n (code: number | string): number | string;\n /**\n * A list of all the supported status codes.\n */\n codes: number[];\n /**\n * A dictionary with the status texts and their corresponding status codes.\n */\n code: Record<string, number | undefined>;\n /**\n * A dictionary with the status codes and their corresponding status texts, for\n * responses that expect an empty body.\n */\n empty: Record<number, boolean | undefined>;\n /**\n * A dictionary with the status codes and their corresponding status texts.\n */\n message: Record<number, string | undefined>;\n /**\n * A dictionary with status codes for responses that are valid for redirections.\n */\n redirect: Record<number, boolean | undefined>;\n /**\n * A dictionary with status codes that should be retried.\n */\n retry: Record<number, boolean | undefined>;\n};\n\nexport { statuses };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,kCAAAA;AAAA;AAAA;AAAA,sBAAqB;","names":["statuses"]}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Escapes a string to be used on `new RegExp(...)`.
3
+ *
4
+ * @param text The text to escape.
5
+ * @group Utilities
6
+ */
7
+ declare const escapeForRegExp: (text: string) => string;
8
+
9
+ export { escapeForRegExp };
@@ -0,0 +1,19 @@
1
+ export { notUndefined } from './fns/others.mjs';
2
+ export { createRouteExpression, removeLeadingSlash, removeSlashes, removeTrailingSlash } from './fns/routes.mjs';
3
+ export { Statuses } from './fns/statuses.mjs';
4
+ export { escapeForRegExp } from './fns/text.mjs';
5
+ export { H as Controller, C as ControllerConnectFn, I as ControllerCreator, F as ControllerCreatorFn, a2 as ControllerLike, O as ControllerProvider, Q as ControllerProviderCreator, M as ControllerProviderCreatorFn, K as ControllerProviderRegisterFn, V as Middleware, R as MiddlewareConnectFn, W as MiddlewareCreator, T as MiddlewareCreatorFn, a1 as MiddlewareLike, $ as MiddlewareProvider, a0 as MiddlewareProviderCreator, Z as MiddlewareProviderCreatorFn, X as MiddlewareProviderRegisterFn, y as Provider, z as ProviderCreator, B as ProviderLike, P as ProviderRegisterFn, A as Providers, D as controller, G as controllerCreator, L as controllerProvider, N as controllerProviderCreator, S as middleware, U as middlewareCreator, Y as middlewareProvider, _ as middlewareProviderCreator, v as provider, w as providerCreator, x as providers } from '../index-Bwf7JHu9.mjs';
6
+ export { default as statuses } from 'statuses';
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 '@homer0/jimple';