@steroidsjs/nest 1.0.1 → 1.0.2
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/README.md +8 -1
- package/infrastructure/filters/ValidationExceptionFilter.d.ts +5 -0
- package/infrastructure/filters/ValidationExceptionFilter.js +40 -0
- package/infrastructure/filters/ValidationExceptionFilter.js.map +1 -0
- package/package.json +4 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/usecases/exceptions/ValidationException.d.ts +6 -0
- package/usecases/exceptions/ValidationException.js +10 -0
- package/usecases/exceptions/ValidationException.js.map +1 -0
- package/usecases/helpers/ValidationHelper.d.ts +2 -0
- package/usecases/helpers/ValidationHelper.js +13 -0
- package/usecases/helpers/ValidationHelper.js.map +1 -0
- package/usecases/interfaces/IFormError.d.ts +3 -0
- package/usecases/interfaces/IFormError.js +3 -0
- package/usecases/interfaces/IFormError.js.map +1 -0
- package/usecases/services/CrudService.js +8 -2
- package/usecases/services/CrudService.js.map +1 -1
- package/infrastructure/exception/ValidationException.d.ts +0 -5
- package/infrastructure/exception/ValidationException.js +0 -12
- package/infrastructure/exception/ValidationException.js.map +0 -1
- package/infrastructure/pipes/ValidationPipe.d.ts +0 -4
- package/infrastructure/pipes/ValidationPipe.js +0 -37
- package/infrastructure/pipes/ValidationPipe.js.map +0 -1
package/README.md
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ExceptionFilter, ArgumentsHost } from '@nestjs/common';
|
|
2
|
+
import { ValidationException } from '../../usecases/exceptions/ValidationException';
|
|
3
|
+
export declare class ValidationExceptionFilter implements ExceptionFilter {
|
|
4
|
+
catch(exception: ValidationException, host: ArgumentsHost): void;
|
|
5
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ValidationExceptionFilter = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const class_validator_1 = require("class-validator");
|
|
12
|
+
const ValidationException_1 = require("../../usecases/exceptions/ValidationException");
|
|
13
|
+
let ValidationExceptionFilter = class ValidationExceptionFilter {
|
|
14
|
+
catch(exception, host) {
|
|
15
|
+
const ctx = host.switchToHttp();
|
|
16
|
+
const response = ctx.getResponse();
|
|
17
|
+
let errors;
|
|
18
|
+
if (Array.isArray(exception.errors) && exception.errors[0] instanceof class_validator_1.ValidationError) {
|
|
19
|
+
errors = exception.errors.reduce((result, item) => {
|
|
20
|
+
result[item.property] = []
|
|
21
|
+
.concat(Object.values(item.constraints));
|
|
22
|
+
return result;
|
|
23
|
+
}, {});
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
errors = exception.errors;
|
|
27
|
+
}
|
|
28
|
+
response
|
|
29
|
+
.status(common_1.HttpStatus.BAD_REQUEST)
|
|
30
|
+
.json({
|
|
31
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
32
|
+
errors,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
ValidationExceptionFilter = __decorate([
|
|
37
|
+
(0, common_1.Catch)(ValidationException_1.ValidationException)
|
|
38
|
+
], ValidationExceptionFilter);
|
|
39
|
+
exports.ValidationExceptionFilter = ValidationExceptionFilter;
|
|
40
|
+
//# sourceMappingURL=ValidationExceptionFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationExceptionFilter.js","sourceRoot":"","sources":["../../../src/infrastructure/filters/ValidationExceptionFilter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAiF;AAEjF,qDAAgD;AAChD,uFAAkF;AAGlF,IAAa,yBAAyB,GAAtC,MAAa,yBAAyB;IAClC,KAAK,CAAC,SAA8B,EAAE,IAAmB;QACrD,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAY,CAAC;QAC7C,IAAI,MAAM,CAAC;QACX,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,iCAAe,EAAE;YACnF,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,CAC5B,CAAC,MAAW,EAAE,IAAI,EAAE,EAAE;gBAClB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;qBACrB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;gBAC7C,OAAO,MAAM,CAAC;YAClB,CAAC,EACD,EAAE,CACL,CAAC;SACL;aAAM;YACH,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;SAC7B;QACD,QAAQ;aACH,MAAM,CAAC,mBAAU,CAAC,WAAW,CAAC;aAC9B,IAAI,CAAC;YACF,UAAU,EAAE,mBAAU,CAAC,WAAW;YAClC,MAAM;SACT,CAAC,CAAC;IACX,CAAC;CACJ,CAAA;AAxBY,yBAAyB;IADrC,IAAA,cAAK,EAAC,yCAAmB,CAAC;GACd,yBAAyB,CAwBrC;AAxBY,8DAAyB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steroidsjs/nest",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "tsc && copyfiles ./{package.json,LICENSE,README.md} dist/"
|
|
6
6
|
},
|
|
@@ -26,15 +26,16 @@
|
|
|
26
26
|
"@sqltools/formatter": "^1.2.3",
|
|
27
27
|
"class-transformer": "^0.5.1",
|
|
28
28
|
"class-validator": "^0.13.2",
|
|
29
|
+
"express": "^4.17.2",
|
|
29
30
|
"lodash": "^4.17.21",
|
|
30
31
|
"nestjs-command": "^3.1.1",
|
|
31
32
|
"typeorm": "^0.2.41",
|
|
32
33
|
"uuid": "^8.3.2"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
36
|
+
"@types/node": "^16.11.7",
|
|
35
37
|
"copyfiles": "^2.4.1",
|
|
36
38
|
"tsconfig-paths": "^3.10.1",
|
|
37
|
-
"typescript": "^4.3.5"
|
|
38
|
-
"@types/node": "^16.11.7"
|
|
39
|
+
"typescript": "^4.3.5"
|
|
39
40
|
}
|
|
40
41
|
}
|