@munlib/common 1.0.34 → 1.0.37
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.
|
@@ -2,7 +2,7 @@ import { CustomError } from './custom-error';
|
|
|
2
2
|
export declare class BadRequestError extends CustomError {
|
|
3
3
|
message: string;
|
|
4
4
|
statusCode: number;
|
|
5
|
-
constructor(message: string);
|
|
5
|
+
constructor(message: string, statusCode?: number);
|
|
6
6
|
serializeErrors(): {
|
|
7
7
|
message: string;
|
|
8
8
|
}[];
|
|
@@ -19,10 +19,11 @@ exports.BadRequestError = void 0;
|
|
|
19
19
|
var custom_error_1 = require("./custom-error");
|
|
20
20
|
var BadRequestError = /** @class */ (function (_super) {
|
|
21
21
|
__extends(BadRequestError, _super);
|
|
22
|
-
function BadRequestError(message) {
|
|
22
|
+
function BadRequestError(message, statusCode) {
|
|
23
23
|
var _this = _super.call(this, message) || this;
|
|
24
24
|
_this.message = message;
|
|
25
25
|
_this.statusCode = 400;
|
|
26
|
+
_this.statusCode = statusCode ? _this.statusCode : 400;
|
|
26
27
|
Object.setPrototypeOf(_this, BadRequestError.prototype);
|
|
27
28
|
return _this;
|
|
28
29
|
}
|
|
@@ -7,9 +7,8 @@ exports.requireAuth = void 0;
|
|
|
7
7
|
var not_authorized_error_1 = require("../errors/not-authorized-error");
|
|
8
8
|
var jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
9
9
|
var requireAuth = function (req, res, next) {
|
|
10
|
-
var _a
|
|
10
|
+
var _a;
|
|
11
11
|
if (!((_a = req.session) === null || _a === void 0 ? void 0 : _a.jwt)) {
|
|
12
|
-
console.log("****", (_b = req.session) === null || _b === void 0 ? void 0 : _b.jwt, !((_c = req.session) === null || _c === void 0 ? void 0 : _c.jwt));
|
|
13
12
|
// Si no hay un token JWT en la sesión, devolver Unauthorized
|
|
14
13
|
throw new not_authorized_error_1.NotAuthorizedError();
|
|
15
14
|
}
|