@mondart/nestjs-common-module 1.1.8 → 1.1.9
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/helpers/index.d.ts +3 -0
- package/dist/{helper → helpers}/index.js +3 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/kafka/kafka.service.js +1 -1
- package/dist/services/core-crud.service.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/validators/env.validator.d.ts +3 -2
- package/dist/validators/env.validator.js +11 -3
- package/dist/validators/validation-options.js +2 -2
- package/package.json +1 -1
- package/dist/helper/get-env.d.ts +0 -1
- package/dist/helper/get-env.js +0 -6
- package/dist/helper/index.d.ts +0 -2
- package/dist/helper/multi-inheritance.util.d.ts +0 -1
- package/dist/helper/multi-inheritance.util.js +0 -12
- /package/dist/{helper → helpers}/get-env.helper.d.ts +0 -0
- /package/dist/{helper → helpers}/get-env.helper.js +0 -0
- /package/dist/{helper → helpers}/message-formatter.helper.d.ts +0 -0
- /package/dist/{helper → helpers}/message-formatter.helper.js +0 -0
- /package/dist/{helper → helpers}/multi-inheritance.helper.d.ts +0 -0
- /package/dist/{helper → helpers}/multi-inheritance.helper.js +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare class EnvValidator {
|
|
2
|
-
private readonly
|
|
3
|
-
|
|
2
|
+
private readonly envSchemaClass;
|
|
3
|
+
private readonly extendedClasses;
|
|
4
|
+
constructor(envSchemaClass: any, extendedClasses: any[]);
|
|
4
5
|
validate(configuration: Record<string, unknown>): object;
|
|
5
6
|
}
|
|
@@ -4,11 +4,19 @@ exports.EnvValidator = void 0;
|
|
|
4
4
|
const class_transformer_1 = require("class-transformer");
|
|
5
5
|
const class_validator_1 = require("class-validator");
|
|
6
6
|
class EnvValidator {
|
|
7
|
-
constructor(
|
|
8
|
-
this.
|
|
7
|
+
constructor(envSchemaClass, extendedClasses) {
|
|
8
|
+
this.envSchemaClass = envSchemaClass;
|
|
9
|
+
this.extendedClasses = extendedClasses;
|
|
9
10
|
}
|
|
10
11
|
validate(configuration) {
|
|
11
|
-
|
|
12
|
+
let transformedConfig = {};
|
|
13
|
+
this.extendedClasses.forEach((schema) => {
|
|
14
|
+
transformedConfig = {
|
|
15
|
+
...transformedConfig,
|
|
16
|
+
[schema.name]: (0, class_transformer_1.plainToClass)(schema, configuration),
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
const finalConfig = (0, class_transformer_1.plainToClass)(this.envSchemaClass, transformedConfig, {
|
|
12
20
|
enableImplicitConversion: true,
|
|
13
21
|
});
|
|
14
22
|
const errors = (0, class_validator_1.validateSync)(finalConfig, { skipMissingProperties: false });
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validationOptions = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
-
const
|
|
5
|
+
const helpers_1 = require("../helpers");
|
|
6
6
|
exports.validationOptions = {
|
|
7
7
|
transform: true,
|
|
8
8
|
whitelist: true,
|
|
@@ -17,7 +17,7 @@ function mapValidationErrors(errors) {
|
|
|
17
17
|
return errors.reduce((result, error) => {
|
|
18
18
|
const constraints = error.constraints
|
|
19
19
|
? Object.values(error.constraints)
|
|
20
|
-
.map((message) =>
|
|
20
|
+
.map((message) => helpers_1.MessageFormatter.replace(message, error.property))
|
|
21
21
|
.join(', ')
|
|
22
22
|
: null;
|
|
23
23
|
result[error.property] =
|
package/package.json
CHANGED
package/dist/helper/get-env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function env(key: any, defaultValue?: any): any;
|
package/dist/helper/get-env.js
DELETED
package/dist/helper/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const multiInheritance: (baseClass: any, extendedClasses: any[]) => void;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.multiInheritance = void 0;
|
|
4
|
-
const multiInheritance = (baseClass, extendedClasses) => {
|
|
5
|
-
extendedClasses.forEach((extendedClass) => {
|
|
6
|
-
Object.getOwnPropertyNames(extendedClass.prototype).forEach((name) => {
|
|
7
|
-
Object.defineProperty(baseClass.prototype, name, Object.getOwnPropertyDescriptor(extendedClass.prototype, name) ||
|
|
8
|
-
Object.create(null));
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
exports.multiInheritance = multiInheritance;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|