@misalon/common 1.0.11 → 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
- package/build/events/appointment--created-event.d.ts +2 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +2 -0
- package/build/middlewares/restrict-by-role.d.ts +2 -0
- package/build/middlewares/restrict-by-role.js +14 -0
- package/build/permissions/index.d.ts +9 -0
- package/build/permissions/index.js +12 -0
- package/package.json +1 -1
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Subjects } from "./subjects";
|
2
|
+
import { ServiceCategory } from "./type/service-category";
|
2
3
|
export interface AppointmentCreatedEvent {
|
3
4
|
subject: Subjects.AppointmentCreated;
|
4
5
|
data: {
|
@@ -8,6 +9,7 @@ export interface AppointmentCreatedEvent {
|
|
8
9
|
name: string;
|
9
10
|
price: number;
|
10
11
|
duration: number;
|
12
|
+
category: ServiceCategory;
|
11
13
|
};
|
12
14
|
userId: string;
|
13
15
|
date: string;
|
package/build/index.d.ts
CHANGED
@@ -9,6 +9,7 @@ export * from './middlewares/error-handler';
|
|
9
9
|
export * from './middlewares/require-auth';
|
10
10
|
export * from './middlewares/validate-request';
|
11
11
|
export * from './middlewares/admin-auth';
|
12
|
+
export * from './middlewares/restrict-by-role';
|
12
13
|
export * from './events/base-listener';
|
13
14
|
export * from './events/base-publisher';
|
14
15
|
export * from './events/subjects';
|
@@ -18,3 +19,4 @@ export * from "./events/appointment--created-event";
|
|
18
19
|
export * from "./events/appointment-cancelled-event";
|
19
20
|
export * from './events/type/service-category';
|
20
21
|
export * from './events/type/status';
|
22
|
+
export * from './permissions/index';
|
package/build/index.js
CHANGED
@@ -25,6 +25,7 @@ __exportStar(require("./middlewares/error-handler"), exports);
|
|
25
25
|
__exportStar(require("./middlewares/require-auth"), exports);
|
26
26
|
__exportStar(require("./middlewares/validate-request"), exports);
|
27
27
|
__exportStar(require("./middlewares/admin-auth"), exports);
|
28
|
+
__exportStar(require("./middlewares/restrict-by-role"), exports);
|
28
29
|
__exportStar(require("./events/base-listener"), exports);
|
29
30
|
__exportStar(require("./events/base-publisher"), exports);
|
30
31
|
__exportStar(require("./events/subjects"), exports);
|
@@ -34,3 +35,4 @@ __exportStar(require("./events/appointment--created-event"), exports);
|
|
34
35
|
__exportStar(require("./events/appointment-cancelled-event"), exports);
|
35
36
|
__exportStar(require("./events/type/service-category"), exports);
|
36
37
|
__exportStar(require("./events/type/status"), exports);
|
38
|
+
__exportStar(require("./permissions/index"), exports);
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
// common/src/middlewares/restrict-by-role.ts
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.restrictByRole = void 0;
|
5
|
+
var not_authorized_error_1 = require("../errors/not-authorized-error"); // Adjust path as needed
|
6
|
+
var restrictByRole = function (restrictedRoles) {
|
7
|
+
return function (req, res, next) {
|
8
|
+
if (restrictedRoles.includes(req.currentUser.role)) {
|
9
|
+
throw new not_authorized_error_1.NotAuthorizedError();
|
10
|
+
}
|
11
|
+
next();
|
12
|
+
};
|
13
|
+
};
|
14
|
+
exports.restrictByRole = restrictByRole;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.RestrictedActions = exports.Roles = void 0;
|
4
|
+
exports.Roles = {
|
5
|
+
ADMIN: 'admin',
|
6
|
+
USER: 'user',
|
7
|
+
};
|
8
|
+
exports.RestrictedActions = {
|
9
|
+
CREATE_APPOINTMENT: [exports.Roles.ADMIN], // Admins restricted from creating appointments
|
10
|
+
CANCEL_APPOINTMENT: [exports.Roles.ADMIN], // Admins restricted from canceling appointments
|
11
|
+
MANAGE_SERVICES: [exports.Roles.USER], // Users restricted from managing salon services
|
12
|
+
};
|