@lenne.tech/nest-server 10.8.8 → 10.8.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/core/common/decorators/common-error.decorator.d.ts +27 -0
- package/dist/core/common/decorators/common-error.decorator.js +23 -2
- package/dist/core/common/decorators/common-error.decorator.js.map +1 -1
- package/dist/core/common/pipes/map-and-validate.pipe.js +5 -1
- package/dist/core/common/pipes/map-and-validate.pipe.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/core/common/decorators/common-error.decorator.ts +23 -1
- package/src/core/common/pipes/map-and-validate.pipe.ts +5 -1
|
@@ -29,4 +29,31 @@ export declare const commonErrorSchema: {
|
|
|
29
29
|
};
|
|
30
30
|
type: string;
|
|
31
31
|
};
|
|
32
|
+
export declare const badRequestSchema: {
|
|
33
|
+
properties: {
|
|
34
|
+
message: {
|
|
35
|
+
type: string;
|
|
36
|
+
};
|
|
37
|
+
name: {
|
|
38
|
+
type: string;
|
|
39
|
+
};
|
|
40
|
+
options: {
|
|
41
|
+
additionalProperties: boolean;
|
|
42
|
+
type: string;
|
|
43
|
+
};
|
|
44
|
+
response: {
|
|
45
|
+
additionalProperties: {
|
|
46
|
+
additionalProperties: {
|
|
47
|
+
type: string;
|
|
48
|
+
};
|
|
49
|
+
type: string;
|
|
50
|
+
};
|
|
51
|
+
type: string;
|
|
52
|
+
};
|
|
53
|
+
status: {
|
|
54
|
+
type: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
type: string;
|
|
58
|
+
};
|
|
32
59
|
export declare function ApiCommonErrorResponses(): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.commonErrorSchema = void 0;
|
|
3
|
+
exports.badRequestSchema = exports.commonErrorSchema = void 0;
|
|
4
4
|
exports.ApiCommonErrorResponses = ApiCommonErrorResponses;
|
|
5
5
|
const common_1 = require("@nestjs/common");
|
|
6
6
|
const swagger_1 = require("@nestjs/swagger");
|
|
@@ -21,7 +21,28 @@ exports.commonErrorSchema = {
|
|
|
21
21
|
},
|
|
22
22
|
type: 'object',
|
|
23
23
|
};
|
|
24
|
+
exports.badRequestSchema = {
|
|
25
|
+
properties: {
|
|
26
|
+
message: { type: 'string' },
|
|
27
|
+
name: { type: 'string' },
|
|
28
|
+
options: {
|
|
29
|
+
additionalProperties: true,
|
|
30
|
+
type: 'object',
|
|
31
|
+
},
|
|
32
|
+
response: {
|
|
33
|
+
additionalProperties: {
|
|
34
|
+
additionalProperties: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
},
|
|
37
|
+
type: 'object',
|
|
38
|
+
},
|
|
39
|
+
type: 'object',
|
|
40
|
+
},
|
|
41
|
+
status: { type: 'number' },
|
|
42
|
+
},
|
|
43
|
+
type: 'object',
|
|
44
|
+
};
|
|
24
45
|
function ApiCommonErrorResponses() {
|
|
25
|
-
return (0, common_1.applyDecorators)((0, swagger_1.ApiUnauthorizedResponse)({ schema: exports.commonErrorSchema }), (0, swagger_1.ApiNotFoundResponse)({ schema: exports.commonErrorSchema }), (0, swagger_1.ApiBadRequestResponse)({ schema: exports.
|
|
46
|
+
return (0, common_1.applyDecorators)((0, swagger_1.ApiUnauthorizedResponse)({ schema: exports.commonErrorSchema }), (0, swagger_1.ApiNotFoundResponse)({ schema: exports.commonErrorSchema }), (0, swagger_1.ApiBadRequestResponse)({ schema: exports.badRequestSchema }));
|
|
26
47
|
}
|
|
27
48
|
//# sourceMappingURL=common-error.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common-error.decorator.js","sourceRoot":"","sources":["../../../../src/core/common/decorators/common-error.decorator.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"common-error.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M,EAAE,yBAAiB,EAAE,CAAC,EAClD,IAAA,+BAAqB,EAAC,EAAE,MAAM,EAAE,wBAAgB,EAAE,CAAC,CACpD,CAAC;AACJ,CAAC"}
|
|
@@ -27,7 +27,11 @@ let MapAndValidatePipe = class MapAndValidatePipe {
|
|
|
27
27
|
}
|
|
28
28
|
const errors = await (0, class_validator_1.validate)(value, { forbidUnknownValues: false });
|
|
29
29
|
if (errors.length > 0) {
|
|
30
|
-
|
|
30
|
+
const result = {};
|
|
31
|
+
errors.forEach((e) => {
|
|
32
|
+
result[e.property] = e.constraints;
|
|
33
|
+
});
|
|
34
|
+
throw new common_1.BadRequestException(result);
|
|
31
35
|
}
|
|
32
36
|
return value;
|
|
33
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-and-validate.pipe.js","sourceRoot":"","sources":["../../../../src/core/common/pipes/map-and-validate.pipe.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAkG;AAClG,yDAAoD;AACpD,qDAA2C;AAE3C,0DAAsD;AAG/C,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,KAAK,CAAC,SAAS,CAAC,KAAU,EAAE,QAA0B;QACpD,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC;QAE9B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,QAAQ,IAAI,IAAA,0BAAW,EAAC,QAAQ,CAAC,EAAE,CAAC;YAC9E,OAAO,KAAK,CAAC;QACf,CAAC;QAGD,IAAI,CAAC,CAAC,KAAK,YAAY,QAAQ,CAAC,EAAE,CAAC;YACjC,IAAK,QAAgB,EAAE,GAAG,EAAE,CAAC;gBAC3B,KAAK,GAAI,QAAgB,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;YACxC,CAAC;iBAAM,CAAC;gBACN,KAAK,GAAG,IAAA,mCAAe,EAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAC3C,CAAC;QACH,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