@munlib/common 1.0.39 → 1.0.41
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/events/types/order-status.d.ts +2 -2
- package/build/events/types/order-status.js +2 -10
- package/build/events/types/queue-group-name.d.ts +6 -0
- package/build/events/types/queue-group-name.js +10 -0
- package/build/middlewares/require-auth.d.ts +7 -3
- package/build/middlewares/require-auth.js +3 -1
- package/package.json +1 -1
|
@@ -3,16 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OrderStatus = void 0;
|
|
4
4
|
var OrderStatus;
|
|
5
5
|
(function (OrderStatus) {
|
|
6
|
-
// When the order has been created, but the
|
|
7
|
-
// ticket it is trying to order has not been reserved
|
|
8
6
|
OrderStatus["Created"] = "created";
|
|
9
|
-
// The ticket the order is trying to reserve has already
|
|
10
|
-
// been reserved, or when the user has cancelled the order.
|
|
11
|
-
// The order expires before payment
|
|
12
7
|
OrderStatus["Cancelled"] = "cancelled";
|
|
13
|
-
|
|
14
|
-
OrderStatus["
|
|
15
|
-
// The order has reserved the ticket and the user has
|
|
16
|
-
// provided payment successfully
|
|
17
|
-
OrderStatus["Complete"] = "complete";
|
|
8
|
+
OrderStatus["Pending"] = "pending";
|
|
9
|
+
OrderStatus["Completed"] = "completed";
|
|
18
10
|
})(OrderStatus || (exports.OrderStatus = OrderStatus = {}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueueGroupNames = void 0;
|
|
4
|
+
var QueueGroupNames;
|
|
5
|
+
(function (QueueGroupNames) {
|
|
6
|
+
QueueGroupNames["ORDER_SERVICE"] = "order-service";
|
|
7
|
+
QueueGroupNames["PRODUCT_SERVICE"] = "product-service";
|
|
8
|
+
QueueGroupNames["EXPIRATION_SERVICE"] = "expiration-service";
|
|
9
|
+
QueueGroupNames["PAYMENT_SERVICE"] = "payment-service";
|
|
10
|
+
})(QueueGroupNames || (exports.QueueGroupNames = QueueGroupNames = {}));
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { Request, Response, NextFunction } from "express";
|
|
2
|
-
interface
|
|
3
|
-
id: string;
|
|
2
|
+
interface UserAttrs {
|
|
4
3
|
email: string;
|
|
4
|
+
password: string;
|
|
5
|
+
isAdmin: boolean;
|
|
6
|
+
name: string;
|
|
7
|
+
phone: string;
|
|
8
|
+
image?: string;
|
|
5
9
|
}
|
|
6
10
|
declare global {
|
|
7
11
|
namespace Express {
|
|
8
12
|
interface Request {
|
|
9
|
-
currentUser?:
|
|
13
|
+
currentUser?: UserAttrs;
|
|
10
14
|
}
|
|
11
15
|
}
|
|
12
16
|
}
|
|
@@ -7,8 +7,9 @@ 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, _b;
|
|
11
11
|
if (!((_a = req.session) === null || _a === void 0 ? void 0 : _a.jwt)) {
|
|
12
|
+
console.log("error 1 en common", (_b = req.session) === null || _b === void 0 ? void 0 : _b.jwt);
|
|
12
13
|
// Si no hay un token JWT en la sesión, devolver Unauthorized
|
|
13
14
|
throw new not_authorized_error_1.NotAuthorizedError();
|
|
14
15
|
}
|
|
@@ -17,6 +18,7 @@ var requireAuth = function (req, res, next) {
|
|
|
17
18
|
req.currentUser = payload;
|
|
18
19
|
}
|
|
19
20
|
catch (err) {
|
|
21
|
+
console.log("error 2 en common", err);
|
|
20
22
|
throw new not_authorized_error_1.NotAuthorizedError();
|
|
21
23
|
}
|
|
22
24
|
next();
|