@wrcb/cb-common 1.0.743 → 1.0.744

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.
@@ -0,0 +1,9 @@
1
+ import { CustomError } from './customError';
2
+ export declare class WrongAppVersionError extends CustomError {
3
+ message: string;
4
+ statusCode: number;
5
+ constructor(message: string);
6
+ serializeErrors(): {
7
+ message: string;
8
+ }[];
9
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WrongAppVersionError = void 0;
4
+ const customError_1 = require("./customError");
5
+ class WrongAppVersionError extends customError_1.CustomError {
6
+ constructor(message) {
7
+ super(message);
8
+ this.message = message;
9
+ this.statusCode = 426;
10
+ Object.setPrototypeOf(this, WrongAppVersionError.prototype);
11
+ }
12
+ serializeErrors() {
13
+ return [{ message: this.message }];
14
+ }
15
+ }
16
+ exports.WrongAppVersionError = WrongAppVersionError;
@@ -1,3 +1,3 @@
1
1
  import { Request, Response, NextFunction } from 'express';
2
2
  import { BadRequestError } from '../server';
3
- export declare const requireRightApiVersion: (req: Request, res: Response, next: NextFunction) => BadRequestError | Response<any, Record<string, any>> | undefined;
3
+ export declare const requireRightApiVersion: (req: Request, res: Response, next: NextFunction) => BadRequestError | undefined;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.requireRightApiVersion = void 0;
4
4
  const server_1 = require("../server");
5
+ const wrongAppVersionError_1 = require("src/errors/wrongAppVersionError");
5
6
  const requireRightApiVersion = (req, res, next) => {
6
7
  try {
7
8
  const tenant = req.headers['x-tenant'];
@@ -11,11 +12,7 @@ const requireRightApiVersion = (req, res, next) => {
11
12
  const backendApiVersion = tenantData.BACKEND_API_VERSION;
12
13
  const appVersion = req.headers['x-app-version'];
13
14
  if (appVersion && appVersion !== backendApiVersion) {
14
- return res.status(426).json({
15
- errors: [{ message: 'AppUpdateRequired' }],
16
- backendApiVersion,
17
- currentVersion: appVersion
18
- });
15
+ throw new wrongAppVersionError_1.WrongAppVersionError('AppUpdateRequired');
19
16
  }
20
17
  }
21
18
  catch (e) { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrcb/cb-common",
3
- "version": "1.0.743",
3
+ "version": "1.0.744",
4
4
  "description": "Common resources between services",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",