pangea-server 3.3.173 → 3.3.175

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.
@@ -10,9 +10,12 @@ function getAppRouter(appVersion, authConfig) {
10
10
  app.use(basePath, this.router);
11
11
  }
12
12
  setRoute(method, path, validate, ...args) {
13
- const middlewares = args.slice(0, -1);
14
- const controller = args[args.length - 1];
15
- this.router[method](path, ...middlewares, (0, call_controller_1.callController)(controller, validate, appVersion, authConfig));
13
+ const lastArg = args[args.length - 1];
14
+ const options = (typeof lastArg === 'function' ? undefined : lastArg);
15
+ const rest = options ? args.slice(0, -1) : args;
16
+ const middlewares = rest.slice(0, -1);
17
+ const controller = rest[rest.length - 1];
18
+ this.router[method](path, ...middlewares, (0, call_controller_1.callController)(controller, validate, appVersion, authConfig, options));
16
19
  }
17
20
  get(path, validate, ...args) {
18
21
  this.setRoute('get', path, validate, ...args);
@@ -1,5 +1,5 @@
1
1
  import { BaseAuth } from '../auth';
2
2
  import type { AuthMap, AuthUsers } from '../auth/auth.types';
3
3
  import type { RouteValidator, RouteValidate } from '../validator/validator.types';
4
- import type { Controller, AuthConfig } from './router.types';
5
- export declare function callController<V extends RouteValidator, AM extends AuthMap, AU extends AuthUsers<AM>, BA extends BaseAuth<AM>, IR extends any>(controller: Controller<V, AM, BA>, validate: RouteValidate<V>, appVersion: string, authConfig: AuthConfig<AM, AU, BA, IR>): (req: Req, res: Res) => Promise<void>;
4
+ import type { Controller, AuthConfig, RouteOptions } from './router.types';
5
+ export declare function callController<V extends RouteValidator, AM extends AuthMap, AU extends AuthUsers<AM>, BA extends BaseAuth<AM>, IR extends any>(controller: Controller<V, AM, BA>, validate: RouteValidate<V>, appVersion: string, authConfig: AuthConfig<AM, AU, BA, IR>, options?: RouteOptions): (req: Req, res: Res) => Promise<void>;
@@ -11,11 +11,13 @@ const database_1 = require("../database");
11
11
  const auth_1 = require("../auth");
12
12
  // validator
13
13
  const validate_request_1 = require("../validator/validate-request");
14
- function callController(controller, validate, appVersion, authConfig) {
14
+ function callController(controller, validate, appVersion, authConfig, options) {
15
15
  const { authMap, authCtor, initAuthCtor, accessToken } = authConfig;
16
16
  return async function (req, res) {
17
17
  const headers = req.headers;
18
- if ((0, helpers_1.getEnvStr)('ENVIRONMENT') !== 'development' && appVersion !== headers['x-app-version']) {
18
+ if ((0, helpers_1.getEnvStr)('ENVIRONMENT') !== 'development' &&
19
+ !options?.skipAppVersionCheck &&
20
+ appVersion !== headers['x-app-version']) {
19
21
  helpers_1.AppError.Throw({ statusCodeName: 'BAD_REQUEST', errorCode: 'APP_VERSION_MISMATCH' });
20
22
  }
21
23
  const inputs = (0, validate_request_1.validateRequest)(validate, req);
@@ -3,10 +3,10 @@ import type { AuthMap, AuthUsers, AuthCtor } from '../auth/auth.types';
3
3
  import type { RouteValidator } from '../validator/validator.types';
4
4
  export type Middleware = (req: Req, res: Res, next: Next) => void;
5
5
  export type Controller<V extends RouteValidator, AM extends AuthMap, BA extends BaseAuth<AM>> = (ctx: Ctx<V>, db: Db, auth: BA) => unknown;
6
- export type SetRouteArgs<V extends RouteValidator, AM extends AuthMap, BA extends BaseAuth<AM>> = [
7
- ...Middleware[],
8
- Controller<V, AM, BA>
9
- ];
6
+ export type RouteOptions = {
7
+ skipAppVersionCheck?: boolean;
8
+ };
9
+ export type SetRouteArgs<V extends RouteValidator, AM extends AuthMap, BA extends BaseAuth<AM>> = [...Middleware[], Controller<V, AM, BA>] | [...Middleware[], Controller<V, AM, BA>, RouteOptions];
10
10
  export type AuthConfig<AM extends AuthMap, AU extends AuthUsers<AM>, BA extends BaseAuth<AM>, IR extends any> = {
11
11
  authMap: AM;
12
12
  authCtor: AuthCtor<AM, AU, BA, IR>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pangea-server",
3
3
  "description": "",
4
- "version": "3.3.173",
4
+ "version": "3.3.175",
5
5
  "engines": {
6
6
  "node": "22.14.0"
7
7
  },