jimpex 11.0.1 → 11.0.2

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 (49) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/app/index.d.ts +1 -1
  3. package/dist/app/jimpex.d.ts +1 -1
  4. package/dist/controllers/common/config.d.ts +1 -1
  5. package/dist/controllers/common/config.js +1 -1
  6. package/dist/controllers/common/config.js.map +1 -1
  7. package/dist/controllers/common/health.d.ts +1 -1
  8. package/dist/controllers/common/index.d.ts +1 -1
  9. package/dist/controllers/common/statics.d.ts +1 -1
  10. package/dist/controllers/index.d.ts +1 -1
  11. package/dist/controllers/utils/gateway.d.ts +3 -3
  12. package/dist/controllers/utils/index.d.ts +1 -1
  13. package/dist/{index-BlSpNHox.d.ts → index-DAUqbQ6h.d.ts} +2 -2
  14. package/dist/index.d.ts +10 -10
  15. package/dist/middlewares/common/errorHandler.d.ts +1 -1
  16. package/dist/middlewares/common/forceHTTPS.d.ts +1 -1
  17. package/dist/middlewares/common/hsts.d.ts +1 -1
  18. package/dist/middlewares/common/index.d.ts +1 -1
  19. package/dist/middlewares/html/fastHTML.d.ts +1 -1
  20. package/dist/middlewares/html/index.d.ts +1 -1
  21. package/dist/middlewares/html/showHTML.d.ts +1 -1
  22. package/dist/middlewares/index.d.ts +1 -1
  23. package/dist/middlewares/utils/index.d.ts +1 -1
  24. package/dist/middlewares/utils/versionValidator.d.ts +1 -1
  25. package/dist/middlewares/utils/versionValidator.js +1 -1
  26. package/dist/middlewares/utils/versionValidator.js.map +1 -1
  27. package/dist/services/common/appError.d.ts +1 -1
  28. package/dist/services/common/httpError.d.ts +1 -1
  29. package/dist/services/common/index.d.ts +1 -1
  30. package/dist/services/common/sendFile.d.ts +1 -1
  31. package/dist/services/frontend/frontendFs.d.ts +1 -1
  32. package/dist/services/frontend/index.d.ts +1 -1
  33. package/dist/services/html/htmlGenerator.d.ts +1 -1
  34. package/dist/services/html/index.d.ts +1 -1
  35. package/dist/services/http/apiClient.d.ts +2 -2
  36. package/dist/services/http/http.d.ts +1 -1
  37. package/dist/services/http/index.d.ts +1 -1
  38. package/dist/services/http/responsesBuilder.d.ts +1 -1
  39. package/dist/services/index.d.ts +6 -6
  40. package/dist/services/utils/ensureBearerToken.d.ts +1 -1
  41. package/dist/services/utils/index.d.ts +1 -1
  42. package/dist/types/events.d.ts +1 -1
  43. package/dist/types/index.d.ts +1 -1
  44. package/dist/types/options.d.ts +1 -1
  45. package/dist/utils/index.d.ts +1 -1
  46. package/dist/utils/wrappers.d.ts +1 -1
  47. package/package.json +10 -10
  48. package/src/controllers/common/config.ts +1 -1
  49. package/src/middlewares/utils/versionValidator.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [11.0.2](https://github.com/homer0/jimpex/compare/11.0.1...11.0.2) (2026-02-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * improve type check for some string params ([63d0f6d](https://github.com/homer0/jimpex/commit/63d0f6d57e83f91b44aebd876e929504d3d9ed23))
7
+ * update dependencies ([df47178](https://github.com/homer0/jimpex/commit/df4717847b7f01dd8771b889f9df5d5c10525dea))
8
+
1
9
  ## [11.0.1](https://github.com/homer0/jimpex/compare/11.0.0...11.0.1) (2026-01-02)
2
10
 
3
11
 
@@ -1,4 +1,4 @@
1
- export { J as Jimpex, j as jimpex } from '../index-BlSpNHox.js';
1
+ export { J as Jimpex, X as jimpex } from '../index-DAUqbQ6h.js';
2
2
  import '../types/express.js';
3
3
  import 'express';
4
4
  import '../types/http.js';
@@ -1,6 +1,6 @@
1
1
  import '@homer0/jimple';
2
2
  import '@homer0/events-hub';
3
- export { J as Jimpex, j as jimpex } from '../index-BlSpNHox.js';
3
+ export { J as Jimpex, X as jimpex } from '../index-DAUqbQ6h.js';
4
4
  import 'express';
5
5
  import '../types/http.js';
6
6
  import '../types/utils.js';
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { C as ControllerConnectFn } from '../../index-BlSpNHox.js';
2
+ import { a as ControllerConnectFn } from '../../index-DAUqbQ6h.js';
3
3
  import { ExpressMiddleware, AsyncExpressMiddleware } from '../../types/express.js';
4
4
  import { SimpleConfig } from '@homer0/simple-config';
5
5
  import { ResponsesBuilder } from '../../services/http/responsesBuilder.js';
@@ -29,7 +29,7 @@ class ConfigController {
29
29
  switchConfig() {
30
30
  return async (req, res, next) => {
31
31
  const { name } = req.params;
32
- if (!name || !this._config.canSwitchConfigs()) {
32
+ if (!name || typeof name !== "string" || !this._config.canSwitchConfigs()) {
33
33
  next();
34
34
  return;
35
35
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/controllers/common/config.ts"],"sourcesContent":["import { controller } from '../../utils/index.js';\nimport type { ResponsesBuilder } from '../../services/index.js';\nimport type {\n Config,\n Response,\n AsyncExpressMiddleware,\n ExpressMiddleware,\n} from '../../types/index.js';\n/**\n * The options to construct a {@link ConfigController}.\n *\n * @group Controllers/Config\n */\nexport type ConfigControllerOptions = {\n /**\n * A dictionary with the dependencies to inject.\n */\n inject: {\n responsesBuilder: ResponsesBuilder;\n config: Config;\n };\n};\n/**\n * The controller class that allows to show and switch the application configuration.\n *\n * @group Controller Classes\n * @group Controllers/Config\n * @prettierignore\n */\nexport class ConfigController {\n /**\n * The service in charge or building the responses.\n */\n protected readonly _responsesBuilder: ResponsesBuilder;\n /**\n * The service in charge of the configuration.\n */\n protected readonly _config: Config;\n /**\n * @param options The options to construct the controller.\n */\n constructor({ inject }: ConfigControllerOptions) {\n this._responsesBuilder = inject.responsesBuilder;\n this._config = inject.config;\n }\n /**\n * Creates the middleware the shows the current configuration.\n */\n showConfig(): ExpressMiddleware {\n return (_, res) => {\n this.respondWithConfig(res);\n };\n }\n /**\n * Creates the middleware the allows to switch the configuration.\n */\n switchConfig(): AsyncExpressMiddleware {\n return async (req, res, next) => {\n const { name } = req.params;\n if (!name || !this._config.canSwitchConfigs()) {\n next();\n return;\n }\n\n try {\n await this._config.switch(name);\n this.respondWithConfig(res);\n } catch (error) {\n next(error);\n }\n };\n }\n /**\n * Utility to respond with the current configuration.\n */\n protected respondWithConfig(res: Response): void {\n const name = this._config.get<string>('name');\n const data = {\n name,\n ...this._config.getConfig<Record<string, unknown>>(),\n };\n\n this._responsesBuilder.json({\n res,\n data,\n });\n }\n}\n/**\n * This controller is kind of special as it will only mount the routes if the\n * `debug.configController` setting of the app configuration is set to `true`.\n *\n * It provides routes for:\n * - `/`: Showing the current configuration.\n * - `/switch/:name`: Switching the configuration, but only if the service allows it.\n *\n * @group Controllers\n * @group Controllers/Config\n */\nexport const configController = controller((app) => {\n const config = app.getConfig();\n const router = app.getRouter();\n if (config.get<boolean | undefined>('debug.configController') !== true) {\n return router;\n }\n\n const ctrl = new ConfigController({\n inject: {\n config,\n responsesBuilder: app.get('responsesBuilder'),\n },\n });\n\n return router.get('/', ctrl.showConfig()).get('/switch/:name', ctrl.switchConfig());\n});\n"],"mappings":"AAAA,SAAS,kBAAkB;AA6BpB,MAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA,EAIT;AAAA;AAAA;AAAA;AAAA,EAIA;AAAA;AAAA;AAAA;AAAA,EAInB,YAAY,EAAE,OAAO,GAA4B;AAC/C,SAAK,oBAAoB,OAAO;AAChC,SAAK,UAAU,OAAO;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA,EAIA,aAAgC;AAC9B,WAAO,CAAC,GAAG,QAAQ;AACjB,WAAK,kBAAkB,GAAG;AAAA,IAC5B;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAIA,eAAuC;AACrC,WAAO,OAAO,KAAK,KAAK,SAAS;AAC/B,YAAM,EAAE,KAAK,IAAI,IAAI;AACrB,UAAI,CAAC,QAAQ,CAAC,KAAK,QAAQ,iBAAiB,GAAG;AAC7C,aAAK;AACL;AAAA,MACF;AAEA,UAAI;AACF,cAAM,KAAK,QAAQ,OAAO,IAAI;AAC9B,aAAK,kBAAkB,GAAG;AAAA,MAC5B,SAAS,OAAO;AACd,aAAK,KAAK;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAIU,kBAAkB,KAAqB;AAC/C,UAAM,OAAO,KAAK,QAAQ,IAAY,MAAM;AAC5C,UAAM,OAAO;AAAA,MACX;AAAA,MACA,GAAG,KAAK,QAAQ,UAAmC;AAAA,IACrD;AAEA,SAAK,kBAAkB,KAAK;AAAA,MAC1B;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAYO,MAAM,mBAAmB,WAAW,CAAC,QAAQ;AAClD,QAAM,SAAS,IAAI,UAAU;AAC7B,QAAM,SAAS,IAAI,UAAU;AAC7B,MAAI,OAAO,IAAyB,wBAAwB,MAAM,MAAM;AACtE,WAAO;AAAA,EACT;AAEA,QAAM,OAAO,IAAI,iBAAiB;AAAA,IAChC,QAAQ;AAAA,MACN;AAAA,MACA,kBAAkB,IAAI,IAAI,kBAAkB;AAAA,IAC9C;AAAA,EACF,CAAC;AAED,SAAO,OAAO,IAAI,KAAK,KAAK,WAAW,CAAC,EAAE,IAAI,iBAAiB,KAAK,aAAa,CAAC;AACpF,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../../src/controllers/common/config.ts"],"sourcesContent":["import { controller } from '../../utils/index.js';\nimport type { ResponsesBuilder } from '../../services/index.js';\nimport type {\n Config,\n Response,\n AsyncExpressMiddleware,\n ExpressMiddleware,\n} from '../../types/index.js';\n/**\n * The options to construct a {@link ConfigController}.\n *\n * @group Controllers/Config\n */\nexport type ConfigControllerOptions = {\n /**\n * A dictionary with the dependencies to inject.\n */\n inject: {\n responsesBuilder: ResponsesBuilder;\n config: Config;\n };\n};\n/**\n * The controller class that allows to show and switch the application configuration.\n *\n * @group Controller Classes\n * @group Controllers/Config\n * @prettierignore\n */\nexport class ConfigController {\n /**\n * The service in charge or building the responses.\n */\n protected readonly _responsesBuilder: ResponsesBuilder;\n /**\n * The service in charge of the configuration.\n */\n protected readonly _config: Config;\n /**\n * @param options The options to construct the controller.\n */\n constructor({ inject }: ConfigControllerOptions) {\n this._responsesBuilder = inject.responsesBuilder;\n this._config = inject.config;\n }\n /**\n * Creates the middleware the shows the current configuration.\n */\n showConfig(): ExpressMiddleware {\n return (_, res) => {\n this.respondWithConfig(res);\n };\n }\n /**\n * Creates the middleware the allows to switch the configuration.\n */\n switchConfig(): AsyncExpressMiddleware {\n return async (req, res, next) => {\n const { name } = req.params;\n if (!name || typeof name !== 'string' || !this._config.canSwitchConfigs()) {\n next();\n return;\n }\n\n try {\n await this._config.switch(name);\n this.respondWithConfig(res);\n } catch (error) {\n next(error);\n }\n };\n }\n /**\n * Utility to respond with the current configuration.\n */\n protected respondWithConfig(res: Response): void {\n const name = this._config.get<string>('name');\n const data = {\n name,\n ...this._config.getConfig<Record<string, unknown>>(),\n };\n\n this._responsesBuilder.json({\n res,\n data,\n });\n }\n}\n/**\n * This controller is kind of special as it will only mount the routes if the\n * `debug.configController` setting of the app configuration is set to `true`.\n *\n * It provides routes for:\n * - `/`: Showing the current configuration.\n * - `/switch/:name`: Switching the configuration, but only if the service allows it.\n *\n * @group Controllers\n * @group Controllers/Config\n */\nexport const configController = controller((app) => {\n const config = app.getConfig();\n const router = app.getRouter();\n if (config.get<boolean | undefined>('debug.configController') !== true) {\n return router;\n }\n\n const ctrl = new ConfigController({\n inject: {\n config,\n responsesBuilder: app.get('responsesBuilder'),\n },\n });\n\n return router.get('/', ctrl.showConfig()).get('/switch/:name', ctrl.switchConfig());\n});\n"],"mappings":"AAAA,SAAS,kBAAkB;AA6BpB,MAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA,EAIT;AAAA;AAAA;AAAA;AAAA,EAIA;AAAA;AAAA;AAAA;AAAA,EAInB,YAAY,EAAE,OAAO,GAA4B;AAC/C,SAAK,oBAAoB,OAAO;AAChC,SAAK,UAAU,OAAO;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA,EAIA,aAAgC;AAC9B,WAAO,CAAC,GAAG,QAAQ;AACjB,WAAK,kBAAkB,GAAG;AAAA,IAC5B;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAIA,eAAuC;AACrC,WAAO,OAAO,KAAK,KAAK,SAAS;AAC/B,YAAM,EAAE,KAAK,IAAI,IAAI;AACrB,UAAI,CAAC,QAAQ,OAAO,SAAS,YAAY,CAAC,KAAK,QAAQ,iBAAiB,GAAG;AACzE,aAAK;AACL;AAAA,MACF;AAEA,UAAI;AACF,cAAM,KAAK,QAAQ,OAAO,IAAI;AAC9B,aAAK,kBAAkB,GAAG;AAAA,MAC5B,SAAS,OAAO;AACd,aAAK,KAAK;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAIU,kBAAkB,KAAqB;AAC/C,UAAM,OAAO,KAAK,QAAQ,IAAY,MAAM;AAC5C,UAAM,OAAO;AAAA,MACX;AAAA,MACA,GAAG,KAAK,QAAQ,UAAmC;AAAA,IACrD;AAEA,SAAK,kBAAkB,KAAK;AAAA,MAC1B;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAYO,MAAM,mBAAmB,WAAW,CAAC,QAAQ;AAClD,QAAM,SAAS,IAAI,UAAU;AAC7B,QAAM,SAAS,IAAI,UAAU;AAC7B,MAAI,OAAO,IAAyB,wBAAwB,MAAM,MAAM;AACtE,WAAO;AAAA,EACT;AAEA,QAAM,OAAO,IAAI,iBAAiB;AAAA,IAChC,QAAQ;AAAA,MACN;AAAA,MACA,kBAAkB,IAAI,IAAI,kBAAkB;AAAA,IAC9C;AAAA,EACF,CAAC;AAED,SAAO,OAAO,IAAI,KAAK,KAAK,WAAW,CAAC,EAAE,IAAI,iBAAiB,KAAK,aAAa,CAAC;AACpF,CAAC;","names":[]}
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { r as JimpexHealthStatus, C as ControllerConnectFn } from '../../index-BlSpNHox.js';
2
+ import { r as JimpexHealthStatus, a as ControllerConnectFn } from '../../index-DAUqbQ6h.js';
3
3
  import { Statuses } from '../../utils/fns/statuses.js';
4
4
  import { AsyncExpressMiddleware } from '../../types/express.js';
5
5
  import { SimpleConfig } from '@homer0/simple-config';
@@ -2,7 +2,7 @@ export { ConfigController, ConfigControllerOptions, configController } from './c
2
2
  export { GetHealthStatus, HealthController, HealthControllerOptions, healthController } from './health.js';
3
3
  export { AddStaticRouteOptions, StaticsController, StaticsControllerConstructorOptions, StaticsControllerCreatorOptions, StaticsControllerFile, StaticsControllerGetMiddlewaresFn, StaticsControllerOptions, StaticsControllerPathsOptions, staticsController } from './statics.js';
4
4
  import '@homer0/jimple';
5
- import '../../index-BlSpNHox.js';
5
+ import '../../index-DAUqbQ6h.js';
6
6
  import '../../types/express.js';
7
7
  import 'express';
8
8
  import '../../types/http.js';
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex, a1 as MiddlewareLike, C as ControllerConnectFn } from '../../index-BlSpNHox.js';
2
+ import { J as Jimpex, H as MiddlewareLike, a as ControllerConnectFn } from '../../index-DAUqbQ6h.js';
3
3
  import mime from 'mime';
4
4
  import { RouterMethod, ExpressMiddleware } from '../../types/express.js';
5
5
  import { DeepPartial } from '../../types/utils.js';
@@ -3,7 +3,7 @@ export { GetHealthStatus, HealthController, HealthControllerOptions, healthContr
3
3
  export { AddStaticRouteOptions, StaticsController, StaticsControllerConstructorOptions, StaticsControllerCreatorOptions, StaticsControllerFile, StaticsControllerGetMiddlewaresFn, StaticsControllerOptions, StaticsControllerPathsOptions, staticsController } from './common/statics.js';
4
4
  export { AddGatewayRouteOptions, GatewayConfig, GatewayConfigEndpointDefinition, GatewayConfigEndpointProps, GatewayConfigEndpoints, GatewayController, GatewayControllerAPIConfig, GatewayControllerAPIConfigOptions, GatewayControllerConstructorOptions, GatewayControllerCreatorOptions, GatewayControllerEndpointInfo, GatewayControllerExtraOptions, GatewayControllerGetMiddlewaresFn, GatewayControllerHeaderOptions, GatewayControllerHelperOptions, GatewayControllerOptions, GatewayControllerRequest, GatewayControllerRoute, GatewayControllerRouteMethod, GatewayHelperService, GatewayHelperServiceBaseFnOptions, GatewayHelperServiceErrorHandler, GatewayHelperServiceErrorHandlerOptions, GatewayHelperServiceRequestReducer, GatewayHelperServiceRequestReducerOptions, GatewayHelperServiceResponseHandler, GatewayHelperServiceResponseReducer, GatewayHelperServiceResponseReducerOptions, GatewayHelperServiceStreamVerification, gatewayController } from './utils/gateway.js';
5
5
  import '@homer0/jimple';
6
- import '../index-BlSpNHox.js';
6
+ import '../index-DAUqbQ6h.js';
7
7
  import '../types/express.js';
8
8
  import 'express';
9
9
  import '../types/http.js';
@@ -1,11 +1,11 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex, a1 as MiddlewareLike, C as ControllerConnectFn, K as ControllerProviderRegisterFn } from '../../index-BlSpNHox.js';
2
+ import { J as Jimpex, H as MiddlewareLike, a as ControllerConnectFn, h as ControllerProviderRegisterFn } from '../../index-DAUqbQ6h.js';
3
3
  import { APIClientOptions } from '@homer0/api-utils';
4
4
  import { RouterMethod, AsyncExpressMiddleware, ExpressMiddleware } from '../../types/express.js';
5
5
  import { Response as Response$1 } from 'node-fetch';
6
6
  import { DeepPartial } from '../../types/utils.js';
7
- import { HTTPFetchOptions, HTTP } from '../../services/http/http.js';
8
- import { Request, Response, NextFunction, Router } from 'express';
7
+ import { HTTP, HTTPFetchOptions } from '../../services/http/http.js';
8
+ import { Router, Request, Response, NextFunction } from 'express';
9
9
  import '../../types/http.js';
10
10
  import 'https';
11
11
  import 'http';
@@ -1,6 +1,6 @@
1
1
  export { AddGatewayRouteOptions, GatewayConfig, GatewayConfigEndpointDefinition, GatewayConfigEndpointProps, GatewayConfigEndpoints, GatewayController, GatewayControllerAPIConfig, GatewayControllerAPIConfigOptions, GatewayControllerConstructorOptions, GatewayControllerCreatorOptions, GatewayControllerEndpointInfo, GatewayControllerExtraOptions, GatewayControllerGetMiddlewaresFn, GatewayControllerHeaderOptions, GatewayControllerHelperOptions, GatewayControllerOptions, GatewayControllerRequest, GatewayControllerRoute, GatewayControllerRouteMethod, GatewayHelperService, GatewayHelperServiceBaseFnOptions, GatewayHelperServiceErrorHandler, GatewayHelperServiceErrorHandlerOptions, GatewayHelperServiceRequestReducer, GatewayHelperServiceRequestReducerOptions, GatewayHelperServiceResponseHandler, GatewayHelperServiceResponseReducer, GatewayHelperServiceResponseReducerOptions, GatewayHelperServiceStreamVerification, gatewayController } from './gateway.js';
2
2
  import '@homer0/jimple';
3
- import '../../index-BlSpNHox.js';
3
+ import '../../index-DAUqbQ6h.js';
4
4
  import '../../types/express.js';
5
5
  import 'express';
6
6
  import '../../types/http.js';
@@ -10,7 +10,7 @@ import 'node-fetch';
10
10
  import 'https';
11
11
  import 'http';
12
12
  import * as _homer0_jimple from '@homer0/jimple';
13
- import { ProviderRegisterFn as ProviderRegisterFn$1, GenericCurriedFn, Jimple } from '@homer0/jimple';
13
+ import { GenericCurriedFn, ProviderRegisterFn as ProviderRegisterFn$1, Jimple } from '@homer0/jimple';
14
14
 
15
15
  /**
16
16
  * The base payload the events emitted by the application send.
@@ -1284,4 +1284,4 @@ declare class Jimpex extends Jimple {
1284
1284
  */
1285
1285
  declare const jimpex: (...args: ConstructorParameters<typeof Jimpex>) => Jimpex;
1286
1286
 
1287
- export { type MiddlewareProvider as $, type Providers as A, type ProviderLike as B, type ControllerConnectFn as C, controller as D, type EventPayload as E, type ControllerCreatorFn as F, controllerCreator as G, type Controller as H, type ControllerCreator as I, Jimpex as J, type ControllerProviderRegisterFn as K, controllerProvider as L, type ControllerProviderCreatorFn as M, controllerProviderCreator as N, type ControllerProvider as O, type ProviderRegisterFn as P, type ControllerProviderCreator as Q, type MiddlewareConnectFn as R, middleware as S, type MiddlewareCreatorFn as T, middlewareCreator as U, type Middleware as V, type MiddlewareCreator as W, type MiddlewareProviderRegisterFn as X, middlewareProvider as Y, type MiddlewareProviderCreatorFn as Z, middlewareProviderCreator as _, type JimpexEvents as a, type MiddlewareProviderCreator as a0, type MiddlewareLike as a1, type ControllerLike as a2, type JimpexEventName as b, type JimpexEventPayload as c, type JimpexReducerEventTargets as d, type JimpexReducerEventPayloads as e, type JimpexReducerEventName as f, type JimpexReducerEventTarget as g, type JimpexReducerEventPayload as h, type JimpexEventNameLike as i, jimpex as j, type JimpexEventListener as k, type Events as l, type JimpexConfigOptions as m, type JimpexStaticsOptions as n, type JimpexExpressOptions as o, type JimpexPathOptions as p, type JimpexServicesOptions as q, type JimpexHealthStatus as r, type JimpexHealthCheckFn as s, type JimpexOptions as t, type JimpexStartCallback as u, provider as v, providerCreator as w, providers as x, type Provider as y, type ProviderCreator as z };
1287
+ export { middlewareProviderCreator as $, type JimpexStartCallback as A, type JimpexStaticsOptions as B, type Controller as C, type MiddlewareConnectFn as D, type EventPayload as E, type MiddlewareCreator as F, type MiddlewareCreatorFn as G, type MiddlewareLike as H, type MiddlewareProvider as I, Jimpex as J, type MiddlewareProviderCreator as K, type MiddlewareProviderCreatorFn as L, type Middleware as M, type MiddlewareProviderRegisterFn as N, type ProviderCreator as O, type Provider as P, type ProviderLike as Q, type ProviderRegisterFn as R, type Providers as S, controller as T, controllerCreator as U, controllerProvider as V, controllerProviderCreator as W, jimpex as X, middleware as Y, middlewareCreator as Z, middlewareProvider as _, type ControllerConnectFn as a, provider as a0, providerCreator as a1, providers as a2, type ControllerCreator as b, type ControllerCreatorFn as c, type ControllerLike as d, type ControllerProvider as e, type ControllerProviderCreator as f, type ControllerProviderCreatorFn as g, type ControllerProviderRegisterFn as h, type Events as i, type JimpexConfigOptions as j, type JimpexEventListener as k, type JimpexEventName as l, type JimpexEventNameLike as m, type JimpexEventPayload as n, type JimpexEvents as o, type JimpexExpressOptions as p, type JimpexHealthCheckFn as q, type JimpexHealthStatus as r, type JimpexOptions as s, type JimpexPathOptions as t, type JimpexReducerEventName as u, type JimpexReducerEventPayload as v, type JimpexReducerEventPayloads as w, type JimpexReducerEventTarget as x, type JimpexReducerEventTargets as y, type JimpexServicesOptions as z };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- 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, E as EventPayload, l as Events, J as Jimpex, 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, 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, j as jimpex, S as middleware, U as middlewareCreator, Y as middlewareProvider, _ as middlewareProviderCreator, v as provider, w as providerCreator, x as providers } from './index-BlSpNHox.js';
1
+ export { C as Controller, a as ControllerConnectFn, b as ControllerCreator, c as ControllerCreatorFn, d as ControllerLike, e as ControllerProvider, f as ControllerProviderCreator, g as ControllerProviderCreatorFn, h as ControllerProviderRegisterFn, E as EventPayload, i as Events, J as Jimpex, j as JimpexConfigOptions, k as JimpexEventListener, l as JimpexEventName, m as JimpexEventNameLike, n as JimpexEventPayload, o as JimpexEvents, p as JimpexExpressOptions, q as JimpexHealthCheckFn, r as JimpexHealthStatus, s as JimpexOptions, t as JimpexPathOptions, u as JimpexReducerEventName, v as JimpexReducerEventPayload, w as JimpexReducerEventPayloads, x as JimpexReducerEventTarget, y as JimpexReducerEventTargets, z as JimpexServicesOptions, A as JimpexStartCallback, B as JimpexStaticsOptions, M as Middleware, D as MiddlewareConnectFn, F as MiddlewareCreator, G as MiddlewareCreatorFn, H as MiddlewareLike, I as MiddlewareProvider, K as MiddlewareProviderCreator, L as MiddlewareProviderCreatorFn, N as MiddlewareProviderRegisterFn, P as Provider, O as ProviderCreator, Q as ProviderLike, R as ProviderRegisterFn, S as Providers, T as controller, U as controllerCreator, V as controllerProvider, W as controllerProviderCreator, X as jimpex, Y as middleware, Z as middlewareCreator, _ as middlewareProvider, $ as middlewareProviderCreator, a0 as provider, a1 as providerCreator, a2 as providers } from './index-DAUqbQ6h.js';
2
2
  export { AsyncExpressMiddleware, ExpressErrorHandler, ExpressMiddleware, ExpressMiddlewareLike, RouterMethod } from './types/express.js';
3
3
  export { JimpexHTTP2Options, JimpexHTTPSCredentials, JimpexHTTPSOptions, JimpexServer, JimpexServerInstance, NodeFetch } from './types/http.js';
4
4
  export { DeepPartial, DeepReadonly, Dict, NoStringIndex } from './types/utils.js';
@@ -25,20 +25,20 @@ export { notUndefined } from './utils/fns/others.js';
25
25
  export { createRouteExpression, removeLeadingSlash, removeSlashes, removeTrailingSlash } from './utils/fns/routes.js';
26
26
  export { Statuses } from './utils/fns/statuses.js';
27
27
  export { escapeForRegExp } from './utils/fns/text.js';
28
- export { Express, NextFunction, Request, Response, Router } from 'express';
29
- export { Response as HTTPResponse } from 'node-fetch';
30
- export { Server as HTTPSServer } from 'https';
31
- export { Server as HTTPServer } from 'http';
28
+ export { APIClient, APIClientConfig, APIClientConstructorOptions, APIClientProviderOptions, APIClientSettings, EndpointsType, apiClientProvider } from './services/http/apiClient.js';
32
29
  export { AppError, AppErrorClass, AppErrorContext, CreateAppErrorFn, appErrorProvider, createAppError } from './services/common/appError.js';
33
30
  export { CreateHTTPErrorFn, HTTPError, HTTPErrorClass, createHTTPError, httpErrorProvider } from './services/common/httpError.js';
34
- export { SendFile, SendFileGeneratorOptions, SendFileOptions, sendFile, sendFileProvider } from './services/common/sendFile.js';
35
- export { FrontendFs, FrontendFsOptions, frontendFsProvider } from './services/frontend/frontendFs.js';
36
- export { HTMLGenerator, HTMLGeneratorConstructorOptions, HTMLGeneratorOptions, HTMLGeneratorProviderOptions, HTMLGeneratorValuesService, htmlGeneratorProvider } from './services/html/htmlGenerator.js';
31
+ export { EnsureBearerConstructorOptions, EnsureBearerToken, EnsureBearerTokenErrorOptions, EnsureBearerTokenOptions, EnsureBearerTokenProviderOptions, ensureBearerTokenProvider } from './services/utils/ensureBearerToken.js';
37
32
  export { ErrorResponse } from '@homer0/api-utils';
38
- export { APIClient, APIClientConfig, APIClientConstructorOptions, APIClientProviderOptions, APIClientSettings, EndpointsType, apiClientProvider } from './services/http/apiClient.js';
33
+ export { Express, NextFunction, Request, Response, Router } from 'express';
34
+ export { FrontendFs, FrontendFsOptions, frontendFsProvider } from './services/frontend/frontendFs.js';
39
35
  export { GetCustomHeadersFromRequestOptions, HTTP, HTTPConstructorOptions, HTTPFetchBody, HTTPFetchOptions, HTTPOptions, httpProvider } from './services/http/http.js';
36
+ export { HTMLGenerator, HTMLGeneratorConstructorOptions, HTMLGeneratorOptions, HTMLGeneratorProviderOptions, HTMLGeneratorValuesService, htmlGeneratorProvider } from './services/html/htmlGenerator.js';
40
37
  export { HTMLPostMessageResponseOptions, JSONResponseOptions, ResponsesBuilder, ResponsesBuilderConstructorOptions, responsesBuilderProvider } from './services/http/responsesBuilder.js';
41
- export { EnsureBearerConstructorOptions, EnsureBearerToken, EnsureBearerTokenErrorOptions, EnsureBearerTokenOptions, EnsureBearerTokenProviderOptions, ensureBearerTokenProvider } from './services/utils/ensureBearerToken.js';
38
+ export { Response as HTTPResponse } from 'node-fetch';
39
+ export { Server as HTTPSServer } from 'https';
40
+ export { Server as HTTPServer } from 'http';
41
+ export { SendFile, SendFileGeneratorOptions, SendFileOptions, sendFile, sendFileProvider } from './services/common/sendFile.js';
42
42
  export { default as statuses } from 'statuses';
43
43
  import '@homer0/jimple';
44
44
  import 'spdy';
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex, R as MiddlewareConnectFn } from '../../index-BlSpNHox.js';
2
+ import { J as Jimpex, D as MiddlewareConnectFn } from '../../index-DAUqbQ6h.js';
3
3
  import { ExpressErrorHandler } from '../../types/express.js';
4
4
  import { Statuses } from '../../utils/fns/statuses.js';
5
5
  import { SimpleLogger } from '@homer0/simple-logger';
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex, R as MiddlewareConnectFn } from '../../index-BlSpNHox.js';
2
+ import { J as Jimpex, D as MiddlewareConnectFn } from '../../index-DAUqbQ6h.js';
3
3
  import { ExpressMiddleware } from '../../types/express.js';
4
4
  import '../../types/http.js';
5
5
  import 'https';
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex, R as MiddlewareConnectFn } from '../../index-BlSpNHox.js';
2
+ import { J as Jimpex, D as MiddlewareConnectFn } from '../../index-DAUqbQ6h.js';
3
3
  import { ExpressMiddleware } from '../../types/express.js';
4
4
  import '../../types/http.js';
5
5
  import 'https';
@@ -2,7 +2,7 @@ export { ErrorHandler, ErrorHandlerConstructorOptions, ErrorHandlerOptions, Erro
2
2
  export { ForceHTTPS, ForceHTTPSOptions, ForceHTTPSPartialOptions, forceHTTPSMiddleware } from './forceHTTPS.js';
3
3
  export { HSTS, HSTSMiddlewareOptions, HSTSMiddlewarePartialOptions, HSTSMiddlewareSettings, hstsMiddleware } from './hsts.js';
4
4
  import '@homer0/jimple';
5
- import '../../index-BlSpNHox.js';
5
+ import '../../index-DAUqbQ6h.js';
6
6
  import '../../types/express.js';
7
7
  import 'express';
8
8
  import '../../types/http.js';
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { l as Events, J as Jimpex, R as MiddlewareConnectFn } from '../../index-BlSpNHox.js';
2
+ import { i as Events, J as Jimpex, D as MiddlewareConnectFn } from '../../index-DAUqbQ6h.js';
3
3
  import { AsyncExpressMiddleware } from '../../types/express.js';
4
4
  import { SendFile } from '../../services/common/sendFile.js';
5
5
  import { HTMLGenerator } from '../../services/html/htmlGenerator.js';
@@ -1,7 +1,7 @@
1
1
  export { FastHTML, FastHTMLConstructorOptions, FastHTMLMiddlewareOptions, FastHTMLOptions, fastHTMLMiddleware } from './fastHTML.js';
2
2
  export { ShowHTML, ShowHTMLConstructorOptions, ShowHTMLMiddlewareOptions, ShowHTMLOptions, showHTMLMiddleware } from './showHTML.js';
3
3
  import '@homer0/jimple';
4
- import '../../index-BlSpNHox.js';
4
+ import '../../index-DAUqbQ6h.js';
5
5
  import '../../types/express.js';
6
6
  import 'express';
7
7
  import '../../types/http.js';
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex, R as MiddlewareConnectFn } from '../../index-BlSpNHox.js';
2
+ import { J as Jimpex, D as MiddlewareConnectFn } from '../../index-DAUqbQ6h.js';
3
3
  import { AsyncExpressMiddleware } from '../../types/express.js';
4
4
  import { SendFile } from '../../services/common/sendFile.js';
5
5
  import { HTMLGenerator } from '../../services/html/htmlGenerator.js';
@@ -5,7 +5,7 @@ export { FastHTML, FastHTMLConstructorOptions, FastHTMLMiddlewareOptions, FastHT
5
5
  export { ShowHTML, ShowHTMLConstructorOptions, ShowHTMLMiddlewareOptions, ShowHTMLOptions, showHTMLMiddleware } from './html/showHTML.js';
6
6
  export { VersionValidator, VersionValidatorConstructorOptions, VersionValidatorLatestOptions, VersionValidatorMiddlewareOptions, VersionValidatorOptions, VersionValidatorPartialOptions, VersionValidatorPopupOptions, versionValidatorMiddleware } from './utils/versionValidator.js';
7
7
  import '@homer0/jimple';
8
- import '../index-BlSpNHox.js';
8
+ import '../index-DAUqbQ6h.js';
9
9
  import '../types/express.js';
10
10
  import 'express';
11
11
  import '../types/http.js';
@@ -1,6 +1,6 @@
1
1
  export { VersionValidator, VersionValidatorConstructorOptions, VersionValidatorLatestOptions, VersionValidatorMiddlewareOptions, VersionValidatorOptions, VersionValidatorPartialOptions, VersionValidatorPopupOptions, versionValidatorMiddleware } from './versionValidator.js';
2
2
  import '@homer0/jimple';
3
- import '../../index-BlSpNHox.js';
3
+ import '../../index-DAUqbQ6h.js';
4
4
  import '../../types/express.js';
5
5
  import 'express';
6
6
  import '../../types/http.js';
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex, R as MiddlewareConnectFn } from '../../index-BlSpNHox.js';
2
+ import { J as Jimpex, D as MiddlewareConnectFn } from '../../index-DAUqbQ6h.js';
3
3
  import { ExpressMiddleware } from '../../types/express.js';
4
4
  import { Statuses } from '../../utils/fns/statuses.js';
5
5
  import { DeepPartial } from '../../types/utils.js';
@@ -51,7 +51,7 @@ class VersionValidator {
51
51
  getMiddleware() {
52
52
  return (req, res, next) => {
53
53
  const { version } = req.params;
54
- if (!version) {
54
+ if (!version || typeof version !== "string") {
55
55
  next();
56
56
  return;
57
57
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/middlewares/utils/versionValidator.ts"],"sourcesContent":["import { deepAssignWithOverwrite } from '@homer0/deep-assign';\nimport { middlewareCreator, type Statuses } from '../../utils/index.js';\nimport { DeepPartial, Request, ExpressMiddleware } from '../../types/index.js';\nimport type { HTTPErrorClass, ResponsesBuilder } from '../../services/index.js';\n/**\n * The options for how the middleware should behave if the requested version is `latest`.\n *\n * @group Middlewares/VersionValidator\n */\nexport type VersionValidatorLatestOptions = {\n /**\n * Whether or not the middleware should validate the _\"latest version\"_.\n *\n * @default true\n */\n allow: boolean;\n /**\n * The name of the _\"latest version\"_. Basically, `req.params.version` must match with\n * this property in order to be consider \"latest\".\n *\n * @default 'latest'\n */\n name: string;\n};\n/**\n * The options for how to detect if the request comes from a popup and how to compose the\n * post message the middleware will use to respond.\n *\n * @group Middlewares/VersionValidator\n */\nexport type VersionValidatorPopupOptions = {\n /**\n * The name of the query string variable the middleware will check in order to identify\n * whether the request comes from a popup or not. The variable must have `'true'` as its\n * value.\n *\n * @default 'popup'\n */\n variable: string;\n /**\n * The title of the page that will be generated to respond in case the versions don't\n * match.\n *\n * @default 'Conflict'\n */\n title: string;\n /**\n * The contents of the post message the generated page will send if the versions don't\n * match.\n *\n * @default 'version:conflict'\n */\n message: string;\n};\n/**\n * The options used to customize a {@link VersionValidator} instance.\n *\n * @group Middlewares/VersionValidator\n */\nexport type VersionValidatorOptions = {\n /**\n * The version used to validate the requests.\n */\n version: string;\n /**\n * The options for how the middleware should behave if the requested version is\n * `latest`.\n */\n latest: VersionValidatorLatestOptions;\n /**\n * The options for how to detect if the request comes from a popup and how to compose\n * the post message the middleware will use to respond.\n */\n popup: VersionValidatorPopupOptions;\n /**\n * The error message to show when the version is invalid.\n *\n * @default \"The application version doesn't match\"\n * @prettierignore\n */\n error: string;\n};\n/**\n * A partial version of the {@link VersionValidatorOptions}, to be used in the constructor\n * and the middleware creator. The reason it omits `version` it's because for the\n * constructor it's required, but for the middleware creator it's not.\n *\n * @group Middlewares/VersionValidator\n */\nexport type VersionValidatorPartialOptions = DeepPartial<\n Omit<VersionValidatorOptions, 'version'>\n>;\n/**\n * The options to construct a {@link VersionValidator}.\n *\n * @group Middlewares/VersionValidator\n */\nexport type VersionValidatorConstructorOptions = VersionValidatorPartialOptions & {\n /**\n * The version used to validate the requests.\n */\n version: string;\n /**\n * A dictionary with the dependencies to inject.\n */\n inject: {\n HTTPError: HTTPErrorClass;\n responsesBuilder: ResponsesBuilder;\n statuses: Statuses;\n };\n};\n/**\n * The options for the middleware creator that will mount an instance of\n * {@link VersionValidator}.\n *\n * @group Middlewares/VersionValidator\n */\nexport type VersionValidatorMiddlewareOptions = VersionValidatorPartialOptions & {\n /**\n * The version used to validate the requests. This is optional in here because if it's\n * not specified, it will be obtained from the configuration service.\n */\n version?: string;\n};\n/**\n * This is the handler for the middleware/controller that validates the application\n * version.\n * This is useful in cases where you want to restrict the access to specific versions; for\n * example: you have a frontend which needs to be aligned with the \"current\" version of\n * the application, since the frontend won't realize a new version was released, the\n * validator can be used to let the frontend know.\n * Also, it can be configured to handle requests from popups, in which case, instead of\n * generating an error message, it will send a post message.\n *\n * @group Middleware Classes\n * @group Middlewares/VersionValidator\n * @prettierignore\n */\nexport class VersionValidator {\n /**\n * To generate the errors in case the validation fails.\n */\n protected readonly _HTTPError: HTTPErrorClass;\n /**\n * To generate responses for popups.\n */\n protected readonly _responsesBuilder: ResponsesBuilder;\n /**\n * The utility service to get HTTP status codes.\n */\n protected readonly _statuses: Statuses;\n /**\n * The customization options.\n */\n protected readonly _options: VersionValidatorOptions;\n /**\n * @param options The options to construct the class.\n * @throws If no `version` is specified in the options.\n */\n constructor({ inject, version, ...options }: VersionValidatorConstructorOptions) {\n this._HTTPError = inject.HTTPError;\n this._responsesBuilder = inject.responsesBuilder;\n this._statuses = inject.statuses;\n this._options = deepAssignWithOverwrite(\n {\n error: \"The application version doesn't match\",\n latest: {\n allow: true,\n name: 'latest',\n },\n popup: {\n variable: 'popup',\n title: 'Conflict',\n message: 'version:conflict',\n },\n version,\n },\n options,\n );\n\n if (!this._options.version) {\n throw new Error('You need to supply a version');\n }\n }\n /**\n * Generates the middleware that validates the version.\n */\n getMiddleware(): ExpressMiddleware {\n return (req, res, next) => {\n // Get the `version` parameter from the request.\n const { version } = req.params;\n // If no version is present, move on to the next middleware.\n if (!version) {\n next();\n return;\n }\n // If the version matches, or it's a \"latest\" version, move on to the next middleware.\n if (version === this._options.version || this._isTheAllowedLatest(version)) {\n next();\n return;\n }\n\n const status = this._statuses('conflict');\n // If the request comes from a popup, send the post message.\n if (this._isPopup(req)) {\n const { title, message } = this._options.popup;\n this._responsesBuilder.htmlPostMessage({\n res,\n title,\n message,\n status,\n });\n return;\n }\n\n // Every other validation failed, and it's not a popup, so generate an error.\n next(\n new this._HTTPError(this._options.error, status, {\n response: {\n validation: true,\n },\n }),\n );\n };\n }\n /**\n * The customization options.\n */\n get options(): Readonly<VersionValidatorOptions> {\n return deepAssignWithOverwrite({}, this._options);\n }\n /**\n * Helper method that checks if the incoming request is from a popup. It will look for\n * the query string variable defined in the constructor options.\n *\n * @param req The request object sent by the application.\n */\n protected _isPopup(req: Request): boolean {\n const popup = req.query[this._options.popup.variable];\n return !!(popup && String(popup).toLowerCase() === 'true');\n }\n /**\n * Helper method that checks if the \"latest version\" is enabled and if the given version\n * is \"the latest\" (comparing it with the option name).\n *\n * @param version The version received in the request.\n */\n protected _isTheAllowedLatest(version: string): boolean {\n const { allow, name } = this._options.latest;\n return allow && version === name;\n }\n}\n/**\n * A middleware that will validate a `version` request parameter against the application\n * version, and generate an error if they don't match.\n * This is a \"middleware/controller\" because the wrappers for both are the same, the\n * difference is that, for controllers, Jimpex sends a second parameter with the route\n * where they are mounted.\n * By validating the route parameter, the function can know whether the implementation is\n * going to use the middleware by itself or as a route middleware.\n * If used as middleware, it will just return the result of\n * {@link VersionValidator.getMiddleware}; but if used as controller, it will mount it on\n * `[route]/:version/*`.\n *\n * @group Middlewares\n * @group Middlewares/VersionValidator\n */\nexport const versionValidatorMiddleware = middlewareCreator(\n (options: VersionValidatorMiddlewareOptions = {}) =>\n (app, route) => {\n const version = app.getConfig<string>('version');\n const middleware = new VersionValidator({\n inject: {\n HTTPError: app.get('HTTPError'),\n responsesBuilder: app.get('responsesBuilder'),\n statuses: app.get('statuses'),\n },\n version,\n ...options,\n }).getMiddleware();\n\n if (route) {\n const router = app.getRouter();\n return router.all('/:version/*', middleware);\n }\n\n return middleware;\n },\n);\n"],"mappings":"AAAA,SAAS,+BAA+B;AACxC,SAAS,yBAAwC;AAyI1C,MAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA,EAIT;AAAA;AAAA;AAAA;AAAA,EAIA;AAAA;AAAA;AAAA;AAAA,EAIA;AAAA;AAAA;AAAA;AAAA,EAIA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKnB,YAAY,EAAE,QAAQ,SAAS,GAAG,QAAQ,GAAuC;AAC/E,SAAK,aAAa,OAAO;AACzB,SAAK,oBAAoB,OAAO;AAChC,SAAK,YAAY,OAAO;AACxB,SAAK,WAAW;AAAA,MACd;AAAA,QACE,OAAO;AAAA,QACP,QAAQ;AAAA,UACN,OAAO;AAAA,UACP,MAAM;AAAA,QACR;AAAA,QACA,OAAO;AAAA,UACL,UAAU;AAAA,UACV,OAAO;AAAA,UACP,SAAS;AAAA,QACX;AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAEA,QAAI,CAAC,KAAK,SAAS,SAAS;AAC1B,YAAM,IAAI,MAAM,8BAA8B;AAAA,IAChD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAIA,gBAAmC;AACjC,WAAO,CAAC,KAAK,KAAK,SAAS;AAEzB,YAAM,EAAE,QAAQ,IAAI,IAAI;AAExB,UAAI,CAAC,SAAS;AACZ,aAAK;AACL;AAAA,MACF;AAEA,UAAI,YAAY,KAAK,SAAS,WAAW,KAAK,oBAAoB,OAAO,GAAG;AAC1E,aAAK;AACL;AAAA,MACF;AAEA,YAAM,SAAS,KAAK,UAAU,UAAU;AAExC,UAAI,KAAK,SAAS,GAAG,GAAG;AACtB,cAAM,EAAE,OAAO,QAAQ,IAAI,KAAK,SAAS;AACzC,aAAK,kBAAkB,gBAAgB;AAAA,UACrC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AACD;AAAA,MACF;AAGA;AAAA,QACE,IAAI,KAAK,WAAW,KAAK,SAAS,OAAO,QAAQ;AAAA,UAC/C,UAAU;AAAA,YACR,YAAY;AAAA,UACd;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,UAA6C;AAC/C,WAAO,wBAAwB,CAAC,GAAG,KAAK,QAAQ;AAAA,EAClD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOU,SAAS,KAAuB;AACxC,UAAM,QAAQ,IAAI,MAAM,KAAK,SAAS,MAAM,QAAQ;AACpD,WAAO,CAAC,EAAE,SAAS,OAAO,KAAK,EAAE,YAAY,MAAM;AAAA,EACrD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOU,oBAAoB,SAA0B;AACtD,UAAM,EAAE,OAAO,KAAK,IAAI,KAAK,SAAS;AACtC,WAAO,SAAS,YAAY;AAAA,EAC9B;AACF;AAgBO,MAAM,6BAA6B;AAAA,EACxC,CAAC,UAA6C,CAAC,MAC7C,CAAC,KAAK,UAAU;AACd,UAAM,UAAU,IAAI,UAAkB,SAAS;AAC/C,UAAM,aAAa,IAAI,iBAAiB;AAAA,MACtC,QAAQ;AAAA,QACN,WAAW,IAAI,IAAI,WAAW;AAAA,QAC9B,kBAAkB,IAAI,IAAI,kBAAkB;AAAA,QAC5C,UAAU,IAAI,IAAI,UAAU;AAAA,MAC9B;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,CAAC,EAAE,cAAc;AAEjB,QAAI,OAAO;AACT,YAAM,SAAS,IAAI,UAAU;AAC7B,aAAO,OAAO,IAAI,eAAe,UAAU;AAAA,IAC7C;AAEA,WAAO;AAAA,EACT;AACJ;","names":[]}
1
+ {"version":3,"sources":["../../../src/middlewares/utils/versionValidator.ts"],"sourcesContent":["import { deepAssignWithOverwrite } from '@homer0/deep-assign';\nimport { middlewareCreator, type Statuses } from '../../utils/index.js';\nimport { DeepPartial, Request, ExpressMiddleware } from '../../types/index.js';\nimport type { HTTPErrorClass, ResponsesBuilder } from '../../services/index.js';\n/**\n * The options for how the middleware should behave if the requested version is `latest`.\n *\n * @group Middlewares/VersionValidator\n */\nexport type VersionValidatorLatestOptions = {\n /**\n * Whether or not the middleware should validate the _\"latest version\"_.\n *\n * @default true\n */\n allow: boolean;\n /**\n * The name of the _\"latest version\"_. Basically, `req.params.version` must match with\n * this property in order to be consider \"latest\".\n *\n * @default 'latest'\n */\n name: string;\n};\n/**\n * The options for how to detect if the request comes from a popup and how to compose the\n * post message the middleware will use to respond.\n *\n * @group Middlewares/VersionValidator\n */\nexport type VersionValidatorPopupOptions = {\n /**\n * The name of the query string variable the middleware will check in order to identify\n * whether the request comes from a popup or not. The variable must have `'true'` as its\n * value.\n *\n * @default 'popup'\n */\n variable: string;\n /**\n * The title of the page that will be generated to respond in case the versions don't\n * match.\n *\n * @default 'Conflict'\n */\n title: string;\n /**\n * The contents of the post message the generated page will send if the versions don't\n * match.\n *\n * @default 'version:conflict'\n */\n message: string;\n};\n/**\n * The options used to customize a {@link VersionValidator} instance.\n *\n * @group Middlewares/VersionValidator\n */\nexport type VersionValidatorOptions = {\n /**\n * The version used to validate the requests.\n */\n version: string;\n /**\n * The options for how the middleware should behave if the requested version is\n * `latest`.\n */\n latest: VersionValidatorLatestOptions;\n /**\n * The options for how to detect if the request comes from a popup and how to compose\n * the post message the middleware will use to respond.\n */\n popup: VersionValidatorPopupOptions;\n /**\n * The error message to show when the version is invalid.\n *\n * @default \"The application version doesn't match\"\n * @prettierignore\n */\n error: string;\n};\n/**\n * A partial version of the {@link VersionValidatorOptions}, to be used in the constructor\n * and the middleware creator. The reason it omits `version` it's because for the\n * constructor it's required, but for the middleware creator it's not.\n *\n * @group Middlewares/VersionValidator\n */\nexport type VersionValidatorPartialOptions = DeepPartial<\n Omit<VersionValidatorOptions, 'version'>\n>;\n/**\n * The options to construct a {@link VersionValidator}.\n *\n * @group Middlewares/VersionValidator\n */\nexport type VersionValidatorConstructorOptions = VersionValidatorPartialOptions & {\n /**\n * The version used to validate the requests.\n */\n version: string;\n /**\n * A dictionary with the dependencies to inject.\n */\n inject: {\n HTTPError: HTTPErrorClass;\n responsesBuilder: ResponsesBuilder;\n statuses: Statuses;\n };\n};\n/**\n * The options for the middleware creator that will mount an instance of\n * {@link VersionValidator}.\n *\n * @group Middlewares/VersionValidator\n */\nexport type VersionValidatorMiddlewareOptions = VersionValidatorPartialOptions & {\n /**\n * The version used to validate the requests. This is optional in here because if it's\n * not specified, it will be obtained from the configuration service.\n */\n version?: string;\n};\n/**\n * This is the handler for the middleware/controller that validates the application\n * version.\n * This is useful in cases where you want to restrict the access to specific versions; for\n * example: you have a frontend which needs to be aligned with the \"current\" version of\n * the application, since the frontend won't realize a new version was released, the\n * validator can be used to let the frontend know.\n * Also, it can be configured to handle requests from popups, in which case, instead of\n * generating an error message, it will send a post message.\n *\n * @group Middleware Classes\n * @group Middlewares/VersionValidator\n * @prettierignore\n */\nexport class VersionValidator {\n /**\n * To generate the errors in case the validation fails.\n */\n protected readonly _HTTPError: HTTPErrorClass;\n /**\n * To generate responses for popups.\n */\n protected readonly _responsesBuilder: ResponsesBuilder;\n /**\n * The utility service to get HTTP status codes.\n */\n protected readonly _statuses: Statuses;\n /**\n * The customization options.\n */\n protected readonly _options: VersionValidatorOptions;\n /**\n * @param options The options to construct the class.\n * @throws If no `version` is specified in the options.\n */\n constructor({ inject, version, ...options }: VersionValidatorConstructorOptions) {\n this._HTTPError = inject.HTTPError;\n this._responsesBuilder = inject.responsesBuilder;\n this._statuses = inject.statuses;\n this._options = deepAssignWithOverwrite(\n {\n error: \"The application version doesn't match\",\n latest: {\n allow: true,\n name: 'latest',\n },\n popup: {\n variable: 'popup',\n title: 'Conflict',\n message: 'version:conflict',\n },\n version,\n },\n options,\n );\n\n if (!this._options.version) {\n throw new Error('You need to supply a version');\n }\n }\n /**\n * Generates the middleware that validates the version.\n */\n getMiddleware(): ExpressMiddleware {\n return (req, res, next) => {\n // Get the `version` parameter from the request.\n const { version } = req.params;\n // If no version is present, move on to the next middleware.\n if (!version || typeof version !== 'string') {\n next();\n return;\n }\n // If the version matches, or it's a \"latest\" version, move on to the next middleware.\n if (version === this._options.version || this._isTheAllowedLatest(version)) {\n next();\n return;\n }\n\n const status = this._statuses('conflict');\n // If the request comes from a popup, send the post message.\n if (this._isPopup(req)) {\n const { title, message } = this._options.popup;\n this._responsesBuilder.htmlPostMessage({\n res,\n title,\n message,\n status,\n });\n return;\n }\n\n // Every other validation failed, and it's not a popup, so generate an error.\n next(\n new this._HTTPError(this._options.error, status, {\n response: {\n validation: true,\n },\n }),\n );\n };\n }\n /**\n * The customization options.\n */\n get options(): Readonly<VersionValidatorOptions> {\n return deepAssignWithOverwrite({}, this._options);\n }\n /**\n * Helper method that checks if the incoming request is from a popup. It will look for\n * the query string variable defined in the constructor options.\n *\n * @param req The request object sent by the application.\n */\n protected _isPopup(req: Request): boolean {\n const popup = req.query[this._options.popup.variable];\n return !!(popup && String(popup).toLowerCase() === 'true');\n }\n /**\n * Helper method that checks if the \"latest version\" is enabled and if the given version\n * is \"the latest\" (comparing it with the option name).\n *\n * @param version The version received in the request.\n */\n protected _isTheAllowedLatest(version: string): boolean {\n const { allow, name } = this._options.latest;\n return allow && version === name;\n }\n}\n/**\n * A middleware that will validate a `version` request parameter against the application\n * version, and generate an error if they don't match.\n * This is a \"middleware/controller\" because the wrappers for both are the same, the\n * difference is that, for controllers, Jimpex sends a second parameter with the route\n * where they are mounted.\n * By validating the route parameter, the function can know whether the implementation is\n * going to use the middleware by itself or as a route middleware.\n * If used as middleware, it will just return the result of\n * {@link VersionValidator.getMiddleware}; but if used as controller, it will mount it on\n * `[route]/:version/*`.\n *\n * @group Middlewares\n * @group Middlewares/VersionValidator\n */\nexport const versionValidatorMiddleware = middlewareCreator(\n (options: VersionValidatorMiddlewareOptions = {}) =>\n (app, route) => {\n const version = app.getConfig<string>('version');\n const middleware = new VersionValidator({\n inject: {\n HTTPError: app.get('HTTPError'),\n responsesBuilder: app.get('responsesBuilder'),\n statuses: app.get('statuses'),\n },\n version,\n ...options,\n }).getMiddleware();\n\n if (route) {\n const router = app.getRouter();\n return router.all('/:version/*', middleware);\n }\n\n return middleware;\n },\n);\n"],"mappings":"AAAA,SAAS,+BAA+B;AACxC,SAAS,yBAAwC;AAyI1C,MAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA,EAIT;AAAA;AAAA;AAAA;AAAA,EAIA;AAAA;AAAA;AAAA;AAAA,EAIA;AAAA;AAAA;AAAA;AAAA,EAIA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKnB,YAAY,EAAE,QAAQ,SAAS,GAAG,QAAQ,GAAuC;AAC/E,SAAK,aAAa,OAAO;AACzB,SAAK,oBAAoB,OAAO;AAChC,SAAK,YAAY,OAAO;AACxB,SAAK,WAAW;AAAA,MACd;AAAA,QACE,OAAO;AAAA,QACP,QAAQ;AAAA,UACN,OAAO;AAAA,UACP,MAAM;AAAA,QACR;AAAA,QACA,OAAO;AAAA,UACL,UAAU;AAAA,UACV,OAAO;AAAA,UACP,SAAS;AAAA,QACX;AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAEA,QAAI,CAAC,KAAK,SAAS,SAAS;AAC1B,YAAM,IAAI,MAAM,8BAA8B;AAAA,IAChD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAIA,gBAAmC;AACjC,WAAO,CAAC,KAAK,KAAK,SAAS;AAEzB,YAAM,EAAE,QAAQ,IAAI,IAAI;AAExB,UAAI,CAAC,WAAW,OAAO,YAAY,UAAU;AAC3C,aAAK;AACL;AAAA,MACF;AAEA,UAAI,YAAY,KAAK,SAAS,WAAW,KAAK,oBAAoB,OAAO,GAAG;AAC1E,aAAK;AACL;AAAA,MACF;AAEA,YAAM,SAAS,KAAK,UAAU,UAAU;AAExC,UAAI,KAAK,SAAS,GAAG,GAAG;AACtB,cAAM,EAAE,OAAO,QAAQ,IAAI,KAAK,SAAS;AACzC,aAAK,kBAAkB,gBAAgB;AAAA,UACrC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AACD;AAAA,MACF;AAGA;AAAA,QACE,IAAI,KAAK,WAAW,KAAK,SAAS,OAAO,QAAQ;AAAA,UAC/C,UAAU;AAAA,YACR,YAAY;AAAA,UACd;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,UAA6C;AAC/C,WAAO,wBAAwB,CAAC,GAAG,KAAK,QAAQ;AAAA,EAClD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOU,SAAS,KAAuB;AACxC,UAAM,QAAQ,IAAI,MAAM,KAAK,SAAS,MAAM,QAAQ;AACpD,WAAO,CAAC,EAAE,SAAS,OAAO,KAAK,EAAE,YAAY,MAAM;AAAA,EACrD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOU,oBAAoB,SAA0B;AACtD,UAAM,EAAE,OAAO,KAAK,IAAI,KAAK,SAAS;AACtC,WAAO,SAAS,YAAY;AAAA,EAC9B;AACF;AAgBO,MAAM,6BAA6B;AAAA,EACxC,CAAC,UAA6C,CAAC,MAC7C,CAAC,KAAK,UAAU;AACd,UAAM,UAAU,IAAI,UAAkB,SAAS;AAC/C,UAAM,aAAa,IAAI,iBAAiB;AAAA,MACtC,QAAQ;AAAA,QACN,WAAW,IAAI,IAAI,WAAW;AAAA,QAC9B,kBAAkB,IAAI,IAAI,kBAAkB;AAAA,QAC5C,UAAU,IAAI,IAAI,UAAU;AAAA,MAC9B;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,CAAC,EAAE,cAAc;AAEjB,QAAI,OAAO;AACT,YAAM,SAAS,IAAI,UAAU;AAC7B,aAAO,OAAO,IAAI,eAAe,UAAU;AAAA,IAC7C;AAEA,WAAO;AAAA,EACT;AACJ;","names":[]}
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-BlSpNHox.js';
2
+ import { J as Jimpex } from '../../index-DAUqbQ6h.js';
3
3
  import { Statuses } from '../../utils/fns/statuses.js';
4
4
  import '../../types/express.js';
5
5
  import 'express';
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-BlSpNHox.js';
2
+ import { J as Jimpex } from '../../index-DAUqbQ6h.js';
3
3
  import { Statuses } from '../../utils/fns/statuses.js';
4
4
  import { AppError, AppErrorContext } from './appError.js';
5
5
  import '../../types/express.js';
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-BlSpNHox.js';
2
+ import { J as Jimpex } from '../../index-DAUqbQ6h.js';
3
3
  export { AppError, AppErrorClass, AppErrorContext, CreateAppErrorFn, appErrorProvider, createAppError } from './appError.js';
4
4
  export { CreateHTTPErrorFn, HTTPError, HTTPErrorClass, createHTTPError, httpErrorProvider } from './httpError.js';
5
5
  export { SendFile, SendFileGeneratorOptions, SendFileOptions, sendFile, sendFileProvider } from './sendFile.js';
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-BlSpNHox.js';
2
+ import { J as Jimpex } from '../../index-DAUqbQ6h.js';
3
3
  import { Response, NextFunction } from 'express';
4
4
  import { PathUtils } from '@homer0/path-utils';
5
5
  import '../../types/express.js';
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-BlSpNHox.js';
2
+ import { J as Jimpex } from '../../index-DAUqbQ6h.js';
3
3
  import { PathUtils } from '@homer0/path-utils';
4
4
  import fs from 'node:fs/promises';
5
5
  import '../../types/express.js';
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-BlSpNHox.js';
2
+ import { J as Jimpex } from '../../index-DAUqbQ6h.js';
3
3
  export { FrontendFs, FrontendFsOptions, frontendFsProvider } from './frontendFs.js';
4
4
  import '../../types/express.js';
5
5
  import 'express';
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-BlSpNHox.js';
2
+ import { J as Jimpex } from '../../index-DAUqbQ6h.js';
3
3
  import { SimpleLogger } from '@homer0/simple-logger';
4
4
  import { SimpleConfig } from '@homer0/simple-config';
5
5
  import { FrontendFs } from '../frontend/frontendFs.js';
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-BlSpNHox.js';
2
+ import { J as Jimpex } from '../../index-DAUqbQ6h.js';
3
3
  import { HTMLGeneratorProviderOptions } from './htmlGenerator.js';
4
4
  export { HTMLGenerator, HTMLGeneratorConstructorOptions, HTMLGeneratorOptions, HTMLGeneratorValuesService, htmlGeneratorProvider } from './htmlGenerator.js';
5
5
  import '../../types/express.js';
@@ -1,8 +1,8 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-BlSpNHox.js';
2
+ import { J as Jimpex } from '../../index-DAUqbQ6h.js';
3
3
  import { HTTPErrorClass } from '../common/httpError.js';
4
4
  import { HTTP } from './http.js';
5
- import { APIClientOptions, APIClient as APIClient$1, ErrorResponse } from '@homer0/api-utils';
5
+ import { APIClient as APIClient$1, APIClientOptions, ErrorResponse } from '@homer0/api-utils';
6
6
  export { ErrorResponse } from '@homer0/api-utils';
7
7
  import '../../types/express.js';
8
8
  import 'express';
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-BlSpNHox.js';
2
+ import { J as Jimpex } from '../../index-DAUqbQ6h.js';
3
3
  import { Request } from 'express';
4
4
  import { NodeFetch } from '../../types/http.js';
5
5
  import { SimpleLogger } from '@homer0/simple-logger';
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-BlSpNHox.js';
2
+ import { J as Jimpex } from '../../index-DAUqbQ6h.js';
3
3
  export { ErrorResponse } from '@homer0/api-utils';
4
4
  import { APIClientProviderOptions } from './apiClient.js';
5
5
  export { APIClient, APIClientConfig, APIClientConstructorOptions, APIClientSettings, EndpointsType, apiClientProvider } from './apiClient.js';
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-BlSpNHox.js';
2
+ import { J as Jimpex } from '../../index-DAUqbQ6h.js';
3
3
  import { Response } from 'express';
4
4
  import { Statuses } from '../../utils/fns/statuses.js';
5
5
  import { SimpleConfig } from '@homer0/simple-config';
@@ -3,18 +3,18 @@ export { frontendServicesProvider } from './frontend/index.js';
3
3
  export { htmlServicesProvider } from './html/index.js';
4
4
  export { httpServicesProvider } from './http/index.js';
5
5
  export { utilsServicesProvider } from './utils/index.js';
6
+ export { APIClient, APIClientConfig, APIClientConstructorOptions, APIClientProviderOptions, APIClientSettings, EndpointsType, apiClientProvider } from './http/apiClient.js';
6
7
  export { AppError, AppErrorClass, AppErrorContext, CreateAppErrorFn, appErrorProvider, createAppError } from './common/appError.js';
7
8
  export { CreateHTTPErrorFn, HTTPError, HTTPErrorClass, createHTTPError, httpErrorProvider } from './common/httpError.js';
8
- export { SendFile, SendFileGeneratorOptions, SendFileOptions, sendFile, sendFileProvider } from './common/sendFile.js';
9
- export { FrontendFs, FrontendFsOptions, frontendFsProvider } from './frontend/frontendFs.js';
10
- export { HTMLGenerator, HTMLGeneratorConstructorOptions, HTMLGeneratorOptions, HTMLGeneratorProviderOptions, HTMLGeneratorValuesService, htmlGeneratorProvider } from './html/htmlGenerator.js';
9
+ export { EnsureBearerConstructorOptions, EnsureBearerToken, EnsureBearerTokenErrorOptions, EnsureBearerTokenOptions, EnsureBearerTokenProviderOptions, ensureBearerTokenProvider } from './utils/ensureBearerToken.js';
11
10
  export { ErrorResponse } from '@homer0/api-utils';
12
- export { APIClient, APIClientConfig, APIClientConstructorOptions, APIClientProviderOptions, APIClientSettings, EndpointsType, apiClientProvider } from './http/apiClient.js';
11
+ export { FrontendFs, FrontendFsOptions, frontendFsProvider } from './frontend/frontendFs.js';
13
12
  export { GetCustomHeadersFromRequestOptions, HTTP, HTTPConstructorOptions, HTTPFetchBody, HTTPFetchOptions, HTTPOptions, httpProvider } from './http/http.js';
13
+ export { HTMLGenerator, HTMLGeneratorConstructorOptions, HTMLGeneratorOptions, HTMLGeneratorProviderOptions, HTMLGeneratorValuesService, htmlGeneratorProvider } from './html/htmlGenerator.js';
14
14
  export { HTMLPostMessageResponseOptions, JSONResponseOptions, ResponsesBuilder, ResponsesBuilderConstructorOptions, responsesBuilderProvider } from './http/responsesBuilder.js';
15
- export { EnsureBearerConstructorOptions, EnsureBearerToken, EnsureBearerTokenErrorOptions, EnsureBearerTokenOptions, EnsureBearerTokenProviderOptions, ensureBearerTokenProvider } from './utils/ensureBearerToken.js';
15
+ export { SendFile, SendFileGeneratorOptions, SendFileOptions, sendFile, sendFileProvider } from './common/sendFile.js';
16
16
  import '@homer0/jimple';
17
- import '../index-BlSpNHox.js';
17
+ import '../index-DAUqbQ6h.js';
18
18
  import '../types/express.js';
19
19
  import 'express';
20
20
  import '../types/http.js';
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-BlSpNHox.js';
2
+ import { J as Jimpex } from '../../index-DAUqbQ6h.js';
3
3
  import { ExpressMiddleware } from '../../types/express.js';
4
4
  import { Statuses } from '../../utils/fns/statuses.js';
5
5
  import { DeepPartial } from '../../types/utils.js';
@@ -1,5 +1,5 @@
1
1
  import * as _homer0_jimple from '@homer0/jimple';
2
- import { J as Jimpex } from '../../index-BlSpNHox.js';
2
+ import { J as Jimpex } from '../../index-DAUqbQ6h.js';
3
3
  import { EnsureBearerTokenProviderOptions } from './ensureBearerToken.js';
4
4
  export { EnsureBearerConstructorOptions, EnsureBearerToken, EnsureBearerTokenErrorOptions, EnsureBearerTokenOptions, ensureBearerTokenProvider } from './ensureBearerToken.js';
5
5
  import '../../types/express.js';
@@ -1,5 +1,5 @@
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 '../index-BlSpNHox.js';
2
+ export { E as EventPayload, i as Events, k as JimpexEventListener, l as JimpexEventName, m as JimpexEventNameLike, n as JimpexEventPayload, o as JimpexEvents, u as JimpexReducerEventName, v as JimpexReducerEventPayload, w as JimpexReducerEventPayloads, x as JimpexReducerEventTarget, y as JimpexReducerEventTargets } from '../index-DAUqbQ6h.js';
3
3
  import 'express';
4
4
  import './http.js';
5
5
  import 'https';
@@ -1,4 +1,4 @@
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-BlSpNHox.js';
1
+ export { E as EventPayload, i as Events, j as JimpexConfigOptions, k as JimpexEventListener, l as JimpexEventName, m as JimpexEventNameLike, n as JimpexEventPayload, o as JimpexEvents, p as JimpexExpressOptions, q as JimpexHealthCheckFn, r as JimpexHealthStatus, s as JimpexOptions, t as JimpexPathOptions, u as JimpexReducerEventName, v as JimpexReducerEventPayload, w as JimpexReducerEventPayloads, x as JimpexReducerEventTarget, y as JimpexReducerEventTargets, z as JimpexServicesOptions, A as JimpexStartCallback, B as JimpexStaticsOptions } from '../index-DAUqbQ6h.js';
2
2
  export { AsyncExpressMiddleware, ExpressErrorHandler, ExpressMiddleware, ExpressMiddlewareLike, RouterMethod } from './express.js';
3
3
  export { JimpexHTTP2Options, JimpexHTTPSCredentials, JimpexHTTPSOptions, JimpexServer, JimpexServerInstance, NodeFetch } from './http.js';
4
4
  export { DeepPartial, DeepReadonly, Dict, NoStringIndex } from './utils.js';
@@ -1,5 +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 '../index-BlSpNHox.js';
2
+ export { j as JimpexConfigOptions, p as JimpexExpressOptions, q as JimpexHealthCheckFn, r as JimpexHealthStatus, s as JimpexOptions, t as JimpexPathOptions, z as JimpexServicesOptions, A as JimpexStartCallback, B as JimpexStaticsOptions } from '../index-DAUqbQ6h.js';
3
3
  import './express.js';
4
4
  import 'express';
5
5
  import './http.js';
@@ -2,7 +2,7 @@ export { notUndefined } from './fns/others.js';
2
2
  export { createRouteExpression, removeLeadingSlash, removeSlashes, removeTrailingSlash } from './fns/routes.js';
3
3
  export { Statuses } from './fns/statuses.js';
4
4
  export { escapeForRegExp } from './fns/text.js';
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-BlSpNHox.js';
5
+ export { C as Controller, a as ControllerConnectFn, b as ControllerCreator, c as ControllerCreatorFn, d as ControllerLike, e as ControllerProvider, f as ControllerProviderCreator, g as ControllerProviderCreatorFn, h as ControllerProviderRegisterFn, M as Middleware, D as MiddlewareConnectFn, F as MiddlewareCreator, G as MiddlewareCreatorFn, H as MiddlewareLike, I as MiddlewareProvider, K as MiddlewareProviderCreator, L as MiddlewareProviderCreatorFn, N as MiddlewareProviderRegisterFn, P as Provider, O as ProviderCreator, Q as ProviderLike, R as ProviderRegisterFn, S as Providers, T as controller, U as controllerCreator, V as controllerProvider, W as controllerProviderCreator, Y as middleware, Z as middlewareCreator, _ as middlewareProvider, $ as middlewareProviderCreator, a0 as provider, a1 as providerCreator, a2 as providers } from '../index-DAUqbQ6h.js';
6
6
  export { default as statuses } from 'statuses';
7
7
  import '../types/express.js';
8
8
  import 'express';
@@ -1,5 +1,5 @@
1
1
  import '@homer0/jimple';
2
- 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-BlSpNHox.js';
2
+ export { C as Controller, a as ControllerConnectFn, b as ControllerCreator, c as ControllerCreatorFn, d as ControllerLike, e as ControllerProvider, f as ControllerProviderCreator, g as ControllerProviderCreatorFn, h as ControllerProviderRegisterFn, M as Middleware, D as MiddlewareConnectFn, F as MiddlewareCreator, G as MiddlewareCreatorFn, H as MiddlewareLike, I as MiddlewareProvider, K as MiddlewareProviderCreator, L as MiddlewareProviderCreatorFn, N as MiddlewareProviderRegisterFn, P as Provider, O as ProviderCreator, Q as ProviderLike, R as ProviderRegisterFn, S as Providers, T as controller, U as controllerCreator, V as controllerProvider, W as controllerProviderCreator, Y as middleware, Z as middlewareCreator, _ as middlewareProvider, $ as middlewareProviderCreator, a0 as provider, a1 as providerCreator, a2 as providers } from '../index-DAUqbQ6h.js';
3
3
  import '../types/express.js';
4
4
  import '../types/utils.js';
5
5
  import 'express';
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "jimpex",
3
3
  "description": "Express as dependency injection container.",
4
4
  "homepage": "https://homer0.github.io/jimpex/",
5
- "version": "11.0.1",
5
+ "version": "11.0.2",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/homer0/jimpex.git"
@@ -34,7 +34,7 @@
34
34
  "@homer0/simple-config": "^5.0.8",
35
35
  "@homer0/simple-logger": "^5.0.8",
36
36
  "@homer0/ts-async-import": "^3.0.8",
37
- "body-parser": "^2.2.1",
37
+ "body-parser": "^2.2.2",
38
38
  "compression": "^1.8.1",
39
39
  "express": "^5.2.1",
40
40
  "mime": "^4.1.0",
@@ -45,15 +45,15 @@
45
45
  "urijs": "^1.19.11"
46
46
  },
47
47
  "devDependencies": {
48
- "@commitlint/cli": "^20.3.0",
49
- "@commitlint/config-conventional": "^20.3.0",
48
+ "@commitlint/cli": "^20.4.1",
49
+ "@commitlint/config-conventional": "^20.4.1",
50
50
  "@homer0/eslint-plugin": "^14.2.3",
51
51
  "@homer0/prettier-config": "^2.0.0",
52
- "@homer0/prettier-plugin-jsdoc": "^11.0.1",
52
+ "@homer0/prettier-plugin-jsdoc": "^11.0.2",
53
53
  "@homer0/tsconfig": "^4.1.1",
54
54
  "@semantic-release/changelog": "^6.0.3",
55
55
  "@semantic-release/git": "^10.0.1",
56
- "@vitest/coverage-istanbul": "^4.0.16",
56
+ "@vitest/coverage-istanbul": "^4.0.18",
57
57
  "@types/body-parser": "^1.19.6",
58
58
  "@types/compression": "^1.8.1",
59
59
  "@types/express": "^5.0.6",
@@ -67,14 +67,14 @@
67
67
  "is-ci": "^4.1.0",
68
68
  "leasot": "^14.4.0",
69
69
  "lint-staged": "^16.2.7",
70
- "semantic-release": "^25.0.2",
70
+ "semantic-release": "^25.0.3",
71
71
  "ts-node-dev": "^2.0.0",
72
72
  "tsup": "^8.5.1",
73
- "typedoc": "0.28.15",
73
+ "typedoc": "0.28.16",
74
74
  "typescript": "^5.9.3",
75
75
  "unplugin-swc": "^1.5.9",
76
- "vitest": "^4.0.16",
77
- "vite-tsconfig-paths": "^6.0.3"
76
+ "vitest": "^4.0.18",
77
+ "vite-tsconfig-paths": "^6.1.0"
78
78
  },
79
79
  "engine-strict": true,
80
80
  "engines": {
@@ -57,7 +57,7 @@ export class ConfigController {
57
57
  switchConfig(): AsyncExpressMiddleware {
58
58
  return async (req, res, next) => {
59
59
  const { name } = req.params;
60
- if (!name || !this._config.canSwitchConfigs()) {
60
+ if (!name || typeof name !== 'string' || !this._config.canSwitchConfigs()) {
61
61
  next();
62
62
  return;
63
63
  }
@@ -190,7 +190,7 @@ export class VersionValidator {
190
190
  // Get the `version` parameter from the request.
191
191
  const { version } = req.params;
192
192
  // If no version is present, move on to the next middleware.
193
- if (!version) {
193
+ if (!version || typeof version !== 'string') {
194
194
  next();
195
195
  return;
196
196
  }