@wrcb/cb-common 1.0.765 → 1.0.767

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.
@@ -3,10 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.requireRightApiVersion = void 0;
4
4
  const server_1 = require("../server");
5
5
  const wrongAppVersionError_1 = require("../errors/wrongAppVersionError");
6
+ const tenant_1 = require("../types/tenant");
6
7
  const requireRightApiVersion = (req, res, next) => {
7
- const tenant = req.headers['x-tenant'];
8
- if (!tenant)
8
+ const tenantHeader = req.headers['x-tenant'];
9
+ if (!tenantHeader) {
9
10
  throw new server_1.BadRequestError('ProvideTenant');
11
+ }
12
+ const tenant = Object.values(tenant_1.Tenant).find(t => t.toLowerCase() === tenantHeader.toLowerCase());
13
+ if (!tenant) {
14
+ throw new server_1.BadRequestError('InvalidTenant');
15
+ }
10
16
  const tenantData = server_1.TenantDataService.getTenantData(tenant);
11
17
  const backendApiVersion = tenantData.BACKEND_API_VERSION;
12
18
  const appVersion = req.headers['x-app-version'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrcb/cb-common",
3
- "version": "1.0.765",
3
+ "version": "1.0.767",
4
4
  "description": "Common resources between services",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",