@mondart/nestjs-common-module 2.7.6 → 2.7.8
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/constants/index.d.ts +2 -0
- package/dist/constants/index.js +2 -0
- package/dist/constants/nest-exceptions-api-response.const.d.ts +2 -0
- package/dist/constants/nest-exceptions-api-response.const.js +39 -0
- package/dist/decorators/swagger-api-response.decorator.d.ts +1 -1
- package/dist/decorators/swagger-api-response.decorator.js +11 -9
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/validators/index.d.ts +0 -1
- package/dist/validators/index.js +0 -1
- package/package.json +29 -29
- /package/dist/{validators/validation-options.d.ts → constants/validation-options.const.d.ts} +0 -0
- /package/dist/{validators/validation-options.js → constants/validation-options.const.js} +0 -0
package/dist/constants/index.js
CHANGED
|
@@ -15,3 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./validation-constraints.const"), exports);
|
|
18
|
+
__exportStar(require("./validation-options.const"), exports);
|
|
19
|
+
__exportStar(require("./nest-exceptions-api-response.const"), exports);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NestExceptionsApiResponse = void 0;
|
|
4
|
+
const exceptions = require("@nestjs/common/exceptions");
|
|
5
|
+
const helpers_1 = require("../helpers");
|
|
6
|
+
exports.NestExceptionsApiResponse = Object.keys(exceptions).map((exception) => {
|
|
7
|
+
const exceptionInstance = new exceptions[exception]();
|
|
8
|
+
return {
|
|
9
|
+
status: exceptionInstance.status,
|
|
10
|
+
schema: {
|
|
11
|
+
type: 'object',
|
|
12
|
+
properties: {
|
|
13
|
+
name: {
|
|
14
|
+
type: 'string',
|
|
15
|
+
example: helpers_1.ConvertStringCaseHelper.toTitleCase(exceptionInstance?.name),
|
|
16
|
+
},
|
|
17
|
+
message: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
example: exceptionInstance.message,
|
|
20
|
+
},
|
|
21
|
+
status: { type: 'number', example: exceptionInstance.status },
|
|
22
|
+
details: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
cause: {
|
|
26
|
+
type: 'object',
|
|
27
|
+
example: null,
|
|
28
|
+
},
|
|
29
|
+
description: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
example: exceptionInstance.message,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
description: helpers_1.ConvertStringCaseHelper.toTitleCase(exceptionInstance?.name),
|
|
38
|
+
};
|
|
39
|
+
});
|
|
@@ -7,16 +7,18 @@ const dto_1 = require("../dto");
|
|
|
7
7
|
const swagger_2 = require("@nestjs/swagger");
|
|
8
8
|
function CustomApiResponse({ options, }) {
|
|
9
9
|
return function (target, key, descriptor) {
|
|
10
|
-
const dataSchema = options.
|
|
11
|
-
?
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const dataSchema = options.responseDto
|
|
11
|
+
? options.isArray
|
|
12
|
+
? {
|
|
13
|
+
type: 'array',
|
|
14
|
+
items: {
|
|
15
|
+
$ref: (0, swagger_1.getSchemaPath)(options.responseDto),
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
: {
|
|
14
19
|
$ref: (0, swagger_1.getSchemaPath)(options.responseDto),
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
: {
|
|
18
|
-
$ref: (0, swagger_1.getSchemaPath)(options.responseDto),
|
|
19
|
-
};
|
|
20
|
+
}
|
|
21
|
+
: undefined;
|
|
20
22
|
return (0, common_1.applyDecorators)((0, swagger_2.ApiResponse)({
|
|
21
23
|
status: options.status,
|
|
22
24
|
description: options.description,
|