@munlib/common 1.0.120 → 1.0.123
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/build/errors/bad-request-error.d.ts +2 -2
- package/build/errors/bad-request-error.js +2 -1
- package/build/errors/custom-error.d.ts +2 -1
- package/build/errors/database-connection-error.d.ts +2 -1
- package/build/errors/database-connection-error.js +2 -1
- package/build/errors/not-authorized-error.d.ts +2 -1
- package/build/errors/not-authorized-error.js +2 -1
- package/build/errors/not-found-error.d.ts +2 -1
- package/build/errors/not-found-error.js +2 -1
- package/build/errors/request-validation-error.d.ts +1 -1
- package/build/errors/request-validation-error.js +1 -5
- package/build/middlewares/error-handler.js +1 -1
- package/build/middlewares/validate-request.js +0 -1
- package/package.json +1 -1
|
@@ -17,6 +17,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.BadRequestError = void 0;
|
|
19
19
|
var custom_error_1 = require("./custom-error");
|
|
20
|
+
var erroresStatus_1 = require("./erroresStatus");
|
|
20
21
|
var BadRequestError = /** @class */ (function (_super) {
|
|
21
22
|
__extends(BadRequestError, _super);
|
|
22
23
|
function BadRequestError(msg, statusCode) {
|
|
@@ -28,7 +29,7 @@ var BadRequestError = /** @class */ (function (_super) {
|
|
|
28
29
|
return _this;
|
|
29
30
|
}
|
|
30
31
|
BadRequestError.prototype.serializeErrors = function () {
|
|
31
|
-
return
|
|
32
|
+
return { msg: this.message, status: erroresStatus_1.ErrorController.getGeneralStatus(this.statusCode.toString()) };
|
|
32
33
|
};
|
|
33
34
|
return BadRequestError;
|
|
34
35
|
}(custom_error_1.CustomError));
|
|
@@ -17,6 +17,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.DatabaseConnectionError = void 0;
|
|
19
19
|
var custom_error_1 = require("./custom-error");
|
|
20
|
+
var erroresStatus_1 = require("./erroresStatus");
|
|
20
21
|
var DatabaseConnectionError = /** @class */ (function (_super) {
|
|
21
22
|
__extends(DatabaseConnectionError, _super);
|
|
22
23
|
function DatabaseConnectionError() {
|
|
@@ -27,7 +28,7 @@ var DatabaseConnectionError = /** @class */ (function (_super) {
|
|
|
27
28
|
return _this;
|
|
28
29
|
}
|
|
29
30
|
DatabaseConnectionError.prototype.serializeErrors = function () {
|
|
30
|
-
return
|
|
31
|
+
return { msg: this.reason, status: erroresStatus_1.ErrorController.getGeneralStatus(this.statusCode.toString()) };
|
|
31
32
|
};
|
|
32
33
|
return DatabaseConnectionError;
|
|
33
34
|
}(custom_error_1.CustomError));
|
|
@@ -17,6 +17,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.NotAuthorizedError = void 0;
|
|
19
19
|
var custom_error_1 = require("./custom-error");
|
|
20
|
+
var erroresStatus_1 = require("./erroresStatus");
|
|
20
21
|
var NotAuthorizedError = /** @class */ (function (_super) {
|
|
21
22
|
__extends(NotAuthorizedError, _super);
|
|
22
23
|
function NotAuthorizedError() {
|
|
@@ -26,7 +27,7 @@ var NotAuthorizedError = /** @class */ (function (_super) {
|
|
|
26
27
|
return _this;
|
|
27
28
|
}
|
|
28
29
|
NotAuthorizedError.prototype.serializeErrors = function () {
|
|
29
|
-
return
|
|
30
|
+
return { status: erroresStatus_1.ErrorController.getGeneralStatus(this.statusCode.toString()), msg: erroresStatus_1.ErrorController.getErrorMessage(this.statusCode.toString()) };
|
|
30
31
|
};
|
|
31
32
|
return NotAuthorizedError;
|
|
32
33
|
}(custom_error_1.CustomError));
|
|
@@ -17,6 +17,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.NotFoundError = void 0;
|
|
19
19
|
var custom_error_1 = require("./custom-error");
|
|
20
|
+
var erroresStatus_1 = require("./erroresStatus");
|
|
20
21
|
var NotFoundError = /** @class */ (function (_super) {
|
|
21
22
|
__extends(NotFoundError, _super);
|
|
22
23
|
function NotFoundError() {
|
|
@@ -26,7 +27,7 @@ var NotFoundError = /** @class */ (function (_super) {
|
|
|
26
27
|
return _this;
|
|
27
28
|
}
|
|
28
29
|
NotFoundError.prototype.serializeErrors = function () {
|
|
29
|
-
return
|
|
30
|
+
return { status: erroresStatus_1.ErrorController.getGeneralStatus(this.statusCode.toString()), msg: erroresStatus_1.ErrorController.getGeneralStatus(this.statusCode.toString()) };
|
|
30
31
|
};
|
|
31
32
|
return NotFoundError;
|
|
32
33
|
}(custom_error_1.CustomError));
|
|
@@ -29,11 +29,7 @@ var RequestValidationError = /** @class */ (function (_super) {
|
|
|
29
29
|
return _this;
|
|
30
30
|
}
|
|
31
31
|
RequestValidationError.prototype.serializeErrors = function () {
|
|
32
|
-
|
|
33
|
-
console.log("22222222", this.errors);
|
|
34
|
-
return this.errors.map(function (err) {
|
|
35
|
-
return { status: erroresStatus_1.ErrorController.getGeneralStatus(_this.statusCode.toString()), msg: err.msg, field: err.param };
|
|
36
|
-
});
|
|
32
|
+
return { status: erroresStatus_1.ErrorController.getGeneralStatus(this.statusCode.toString()), msg: this.errors[0].msg, field: this.errors[0].param };
|
|
37
33
|
};
|
|
38
34
|
return RequestValidationError;
|
|
39
35
|
}(custom_error_1.CustomError));
|
|
@@ -6,7 +6,7 @@ var erroresStatus_1 = require("../errors/erroresStatus");
|
|
|
6
6
|
var errorHandler = function (err, req, res, next) {
|
|
7
7
|
// Manejo de errores personalizados
|
|
8
8
|
if (err instanceof custom_error_1.CustomError) {
|
|
9
|
-
return res.status(err.statusCode).send(
|
|
9
|
+
return res.status(err.statusCode).send(err.serializeErrors());
|
|
10
10
|
}
|
|
11
11
|
// Manejo de errores genéricos
|
|
12
12
|
var statusCode = 400; // Código de estado por defecto para errores genéricos
|
|
@@ -6,7 +6,6 @@ var request_validation_error_1 = require("../errors/request-validation-error");
|
|
|
6
6
|
var validateRequest = function (req, res, next) {
|
|
7
7
|
var errors = (0, express_validator_1.validationResult)(req);
|
|
8
8
|
if (!errors.isEmpty()) {
|
|
9
|
-
console.log("111111111", errors);
|
|
10
9
|
throw new request_validation_error_1.RequestValidationError(errors.array());
|
|
11
10
|
}
|
|
12
11
|
next();
|