@optimatech88/titomeet-shared-lib 1.0.6 → 1.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimatech88/titomeet-shared-lib",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -80,6 +80,16 @@ enum EventStatus {
80
80
  PUBLISHED
81
81
  }
82
82
 
83
+ model EventCategory {
84
+ id String @id @default(cuid())
85
+ name String
86
+ description String?
87
+ events Event[]
88
+
89
+ createdAt DateTime @default(now())
90
+ updatedAt DateTime @updatedAt
91
+ }
92
+
83
93
  model Event {
84
94
  id String @id @default(cuid())
85
95
  name String
@@ -99,6 +109,8 @@ model Event {
99
109
  chat Chat? // Optional one-to-one relation
100
110
  status EventStatus @default(DRAFT)
101
111
 
112
+ categories EventCategory[]
113
+
102
114
  address Address @relation(fields: [addressId], references: [id])
103
115
  addressId String
104
116
 
@@ -0,0 +1,20 @@
1
+ import { Injectable, NestMiddleware, UnauthorizedException } from '@nestjs/common';
2
+ import { Request, Response, NextFunction } from 'express';
3
+ import { UserRole, User } from '@prisma/client';
4
+
5
+ interface RequestWithUser extends Request {
6
+ user?: User;
7
+ }
8
+
9
+ @Injectable()
10
+ export class AdminMiddleware implements NestMiddleware {
11
+ use(req: RequestWithUser, res: Response, next: NextFunction) {
12
+ const user = req.user;
13
+
14
+ if (!user || !user.role?.includes(UserRole.ADMIN)) {
15
+ throw new UnauthorizedException('Access denied. Admins only.');
16
+ }
17
+
18
+ next();
19
+ }
20
+ }
@@ -51,6 +51,7 @@ export class AuthGuard implements CanActivate {
51
51
  }
52
52
  }
53
53
 
54
+ //optional auth guard
54
55
  @Injectable()
55
56
  export class OptionalAuthGuard implements CanActivate {
56
57
  private prisma: PrismaClient;
@@ -94,3 +95,4 @@ export class OptionalAuthGuard implements CanActivate {
94
95
  return type === 'Bearer' ? token : undefined;
95
96
  }
96
97
  }
98
+
package/src/index.ts CHANGED
@@ -6,7 +6,9 @@ export {
6
6
  EventPrice, Address, Participant,
7
7
  ParticipantStatus,
8
8
  Provider,
9
- ProviderStatus } from '@prisma/client';
9
+ ProviderStatus,
10
+ EventCategory
11
+ } from '@prisma/client';
10
12
 
11
13
  //auth
12
14
  export * from './auth/auth.guard';