@barumetric/common 1.1.4 → 1.1.5
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.
- package/dist/config/env/base-env.class.d.ts +0 -0
- package/dist/config/env/base-env.class.js +1 -0
- package/dist/config/env/database-env.class.d.ts +0 -0
- package/dist/config/env/database-env.class.js +1 -0
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.js +17 -0
- package/dist/config/validate-env.d.ts +2 -0
- package/dist/config/validate-env.js +24 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +4 -2
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './validate-env';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./validate-env"), exports);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateEnv = validateEnv;
|
|
4
|
+
const class_transformer_1 = require("class-transformer");
|
|
5
|
+
const class_validator_1 = require("class-validator");
|
|
6
|
+
function validateEnv(config, envVariablesClass) {
|
|
7
|
+
const validatedConfig = (0, class_transformer_1.plainToClass)(envVariablesClass, config, {
|
|
8
|
+
enableImplicitConversion: true
|
|
9
|
+
});
|
|
10
|
+
const errors = (0, class_validator_1.validateSync)(validatedConfig, {
|
|
11
|
+
skipMissingProperties: false
|
|
12
|
+
});
|
|
13
|
+
if (errors.length > 0) {
|
|
14
|
+
const errorMsg = errors
|
|
15
|
+
.map(error => `\nError in ${error.property}:\n` +
|
|
16
|
+
Object.entries(error.constraints || {})
|
|
17
|
+
.map(([key, value]) => `+ ${key}: ${value}`)
|
|
18
|
+
.join('\n'))
|
|
19
|
+
.join('\n');
|
|
20
|
+
console.error(`\n${errors.toString()}`);
|
|
21
|
+
throw new Error(errorMsg);
|
|
22
|
+
}
|
|
23
|
+
return validatedConfig;
|
|
24
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barumetric/common",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "Core shared components for BaruMetric microservice ecosystem",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
"@barumetric/contracts": "^1.2.5",
|
|
25
25
|
"@nestjs/common": "^11.1.11",
|
|
26
26
|
"@nestjs/config": "^4.0.2",
|
|
27
|
-
"@nestjs/microservices": "^11.1.11"
|
|
27
|
+
"@nestjs/microservices": "^11.1.11",
|
|
28
|
+
"class-transformer": "^0.5.1",
|
|
29
|
+
"class-validator": "^0.14.3"
|
|
28
30
|
}
|
|
29
31
|
}
|