@wrcb/cb-common 1.0.748 → 1.0.749
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.
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { Request, Response, NextFunction } from 'express';
|
|
2
|
-
|
|
3
|
-
export declare const requireRightApiVersion: (req: Request, res: Response, next: NextFunction) => BadRequestError | undefined;
|
|
2
|
+
export declare const requireRightApiVersion: (req: Request, res: Response, next: NextFunction) => void;
|
|
@@ -4,18 +4,15 @@ exports.requireRightApiVersion = void 0;
|
|
|
4
4
|
const server_1 = require("../server");
|
|
5
5
|
const wrongAppVersionError_1 = require("../errors/wrongAppVersionError");
|
|
6
6
|
const requireRightApiVersion = (req, res, next) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
throw new wrongAppVersionError_1.WrongAppVersionError('AppUpdateRequired');
|
|
16
|
-
}
|
|
7
|
+
const tenant = req.headers['x-tenant'];
|
|
8
|
+
if (!tenant)
|
|
9
|
+
throw new server_1.BadRequestError('ProvideTenant');
|
|
10
|
+
const tenantData = server_1.TenantDataService.getTenantData(tenant);
|
|
11
|
+
const backendApiVersion = tenantData.BACKEND_API_VERSION;
|
|
12
|
+
const appVersion = req.headers['x-app-version'];
|
|
13
|
+
if (appVersion && appVersion !== backendApiVersion) {
|
|
14
|
+
throw new wrongAppVersionError_1.WrongAppVersionError('AppUpdateRequired');
|
|
17
15
|
}
|
|
18
|
-
catch (e) { }
|
|
19
16
|
next();
|
|
20
17
|
};
|
|
21
18
|
exports.requireRightApiVersion = requireRightApiVersion;
|