@optimatech88/titomeet-shared-lib 1.0.3 → 1.0.4

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.
Files changed (69) hide show
  1. package/.github/workflows/npm-publish.yml +34 -0
  2. package/.prettierrc +4 -4
  3. package/package.json +1 -1
  4. package/prisma/schema.prisma +27 -2
  5. package/src/auth/auth.guard.ts +96 -96
  6. package/src/auth/auth.module.ts +24 -24
  7. package/src/cache/cache.module.ts +25 -25
  8. package/src/cache/cache.service.ts +19 -19
  9. package/src/index.ts +20 -20
  10. package/src/prisma/prisma.module.ts +9 -9
  11. package/src/prisma/prisma.service.ts +13 -13
  12. package/src/types/index.ts +12 -12
  13. package/src/utils/api/endpoints.ts +6 -6
  14. package/src/utils/constants.ts +13 -13
  15. package/src/utils/events.ts +7 -7
  16. package/src/utils/index.ts +11 -11
  17. package/tsconfig.json +24 -24
  18. package/dist/auth/auth.guard.d.ts +0 -17
  19. package/dist/auth/auth.guard.d.ts.map +0 -1
  20. package/dist/auth/auth.guard.js +0 -89
  21. package/dist/auth/auth.guard.js.map +0 -1
  22. package/dist/auth/auth.module.d.ts +0 -9
  23. package/dist/auth/auth.module.d.ts.map +0 -1
  24. package/dist/auth/auth.module.js +0 -32
  25. package/dist/auth/auth.module.js.map +0 -1
  26. package/dist/cache/cache.module.d.ts +0 -5
  27. package/dist/cache/cache.module.d.ts.map +0 -1
  28. package/dist/cache/cache.module.js +0 -41
  29. package/dist/cache/cache.module.js.map +0 -1
  30. package/dist/cache/cache.service.d.ts +0 -9
  31. package/dist/cache/cache.service.d.ts.map +0 -1
  32. package/dist/cache/cache.service.js +0 -38
  33. package/dist/cache/cache.service.js.map +0 -1
  34. package/dist/index.d.ts +0 -14
  35. package/dist/index.d.ts.map +0 -1
  36. package/dist/index.js +0 -37
  37. package/dist/index.js.map +0 -1
  38. package/dist/prisma/prisma.module.d.ts +0 -3
  39. package/dist/prisma/prisma.module.d.ts.map +0 -1
  40. package/dist/prisma/prisma.module.js +0 -22
  41. package/dist/prisma/prisma.module.js.map +0 -1
  42. package/dist/prisma/prisma.service.d.ts +0 -7
  43. package/dist/prisma/prisma.service.d.ts.map +0 -1
  44. package/dist/prisma/prisma.service.js +0 -24
  45. package/dist/prisma/prisma.service.js.map +0 -1
  46. package/dist/prisma/prisma.service.spec.d.ts +0 -2
  47. package/dist/prisma/prisma.service.spec.d.ts.map +0 -1
  48. package/dist/prisma/prisma.service.spec.js +0 -17
  49. package/dist/prisma/prisma.service.spec.js.map +0 -1
  50. package/dist/types/index.d.ts +0 -12
  51. package/dist/types/index.d.ts.map +0 -1
  52. package/dist/types/index.js +0 -3
  53. package/dist/types/index.js.map +0 -1
  54. package/dist/utils/api/endpoints.d.ts +0 -7
  55. package/dist/utils/api/endpoints.d.ts.map +0 -1
  56. package/dist/utils/api/endpoints.js +0 -10
  57. package/dist/utils/api/endpoints.js.map +0 -1
  58. package/dist/utils/constants.d.ts +0 -3
  59. package/dist/utils/constants.d.ts.map +0 -1
  60. package/dist/utils/constants.js +0 -15
  61. package/dist/utils/constants.js.map +0 -1
  62. package/dist/utils/events.d.ts +0 -7
  63. package/dist/utils/events.d.ts.map +0 -1
  64. package/dist/utils/events.js +0 -10
  65. package/dist/utils/events.js.map +0 -1
  66. package/dist/utils/index.d.ts +0 -8
  67. package/dist/utils/index.d.ts.map +0 -1
  68. package/dist/utils/index.js +0 -14
  69. package/dist/utils/index.js.map +0 -1
@@ -0,0 +1,34 @@
1
+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
+
4
+ name: Node.js Package
5
+
6
+ on:
7
+ push:
8
+ branches:
9
+ - main # Or your main branch
10
+
11
+ jobs:
12
+ build:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: actions/setup-node@v4
17
+ with:
18
+ node-version: 20
19
+ - run: npm ci
20
+ #- run: npm test
21
+
22
+ publish-npm:
23
+ needs: build
24
+ runs-on: ubuntu-latest
25
+ steps:
26
+ - uses: actions/checkout@v4
27
+ - uses: actions/setup-node@v4
28
+ with:
29
+ node-version: 20
30
+ registry-url: https://registry.npmjs.org/
31
+ - run: npm ci
32
+ - run: npm publish
33
+ env:
34
+ NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
package/.prettierrc CHANGED
@@ -1,5 +1,5 @@
1
- {
2
- "singleQuote": true,
3
- "trailingComma": "all",
4
- "endOfLine":"auto"
1
+ {
2
+ "singleQuote": true,
3
+ "trailingComma": "all",
4
+ "endOfLine":"auto"
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimatech88/titomeet-shared-lib",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -34,7 +34,8 @@ model User {
34
34
 
35
35
  accounts Account[]
36
36
  messages Message[]
37
- events Event[]
37
+ events Event[]
38
+ participatedEvents Participant[]
38
39
  }
39
40
 
40
41
  model Account {
@@ -98,6 +99,9 @@ model Event {
98
99
  postedBy User @relation(fields: [postedById], references: [id])
99
100
  postedById String
100
101
 
102
+ // Add participants relation
103
+ participants Participant[]
104
+
101
105
  createdAt DateTime @default(now())
102
106
  updatedAt DateTime @updatedAt
103
107
  }
@@ -107,7 +111,6 @@ model EventPrice {
107
111
  name String // e.g., "Early Bird", "VIP", "Regular"
108
112
  amount Float
109
113
  description String?
110
- capacity Int? // Optional capacity per price tier
111
114
  event Event @relation(fields: [eventId], references: [id])
112
115
  eventId String
113
116
 
@@ -137,3 +140,25 @@ model Message {
137
140
  createdAt DateTime @default(now())
138
141
  updatedAt DateTime @updatedAt
139
142
  }
143
+
144
+ // Add new Participant model
145
+ model Participant {
146
+ id String @id @default(cuid())
147
+ event Event @relation(fields: [eventId], references: [id])
148
+ eventId String
149
+ user User @relation(fields: [userId], references: [id])
150
+ userId String
151
+ status ParticipantStatus @default(PENDING)
152
+
153
+ createdAt DateTime @default(now())
154
+ updatedAt DateTime @updatedAt
155
+
156
+ @@unique([eventId, userId])
157
+ }
158
+
159
+ enum ParticipantStatus {
160
+ PENDING
161
+ CONFIRMED
162
+ CANCELLED
163
+ }
164
+
@@ -1,96 +1,96 @@
1
- import {
2
- CanActivate,
3
- ExecutionContext,
4
- Injectable,
5
- UnauthorizedException,
6
- } from '@nestjs/common';
7
- import { JwtService } from '@nestjs/jwt';
8
- import { PrismaClient } from '@prisma/client';
9
- import { Request } from 'express';
10
- import { IncomingHttpHeaders } from 'http';
11
-
12
- @Injectable()
13
- export class AuthGuard implements CanActivate {
14
- private prisma: PrismaClient;
15
-
16
- constructor(
17
- private jwtService: JwtService,
18
- ) {
19
- this.prisma = new PrismaClient();
20
- }
21
-
22
- async canActivate(context: ExecutionContext): Promise<boolean> {
23
- const request = context.switchToHttp().getRequest();
24
- const token = this.extractTokenFromHeader(request);
25
- if (!token) {
26
- throw new UnauthorizedException();
27
- }
28
- try {
29
- const payload = (await this.jwtService.verifyAsync(token)) as {
30
- userId: string;
31
- };
32
-
33
- const user = await this.prisma.user.findUnique({
34
- where: { id: payload.userId }
35
- });
36
-
37
- if (!user) {
38
- throw new UnauthorizedException();
39
- }
40
-
41
- request['user'] = user;
42
- } catch {
43
- throw new UnauthorizedException();
44
- }
45
- return true;
46
- }
47
-
48
- private extractTokenFromHeader(request: Request & { headers: IncomingHttpHeaders }): string | undefined {
49
- const [type, token] = request.headers.authorization?.split(' ') ?? [];
50
- return type === 'Bearer' ? token : undefined;
51
- }
52
- }
53
-
54
- @Injectable()
55
- export class OptionalAuthGuard implements CanActivate {
56
- private prisma: PrismaClient;
57
-
58
- constructor(
59
- private jwtService: JwtService,
60
- ) {
61
- this.prisma = new PrismaClient();
62
- }
63
-
64
- async canActivate(context: ExecutionContext): Promise<boolean> {
65
- const request = context.switchToHttp().getRequest();
66
- const token = this.extractTokenFromHeader(request);
67
- if (!token) {
68
- return true;
69
- }
70
- try {
71
- const payload = (await this.jwtService.verifyAsync(token)) as {
72
- userId: string;
73
- };
74
-
75
- const user = await this.prisma.user.findUnique({
76
- where: { id: payload.userId }
77
- });
78
-
79
- if (!user) {
80
- throw new UnauthorizedException();
81
- }
82
-
83
- request['user'] = user;
84
-
85
- // Continue without setting user
86
- } catch {
87
- // Continue without setting user
88
- }
89
- return true;
90
- }
91
-
92
- private extractTokenFromHeader(request: Request & { headers: IncomingHttpHeaders }): string | undefined {
93
- const [type, token] = request.headers.authorization?.split(' ') ?? [];
94
- return type === 'Bearer' ? token : undefined;
95
- }
96
- }
1
+ import {
2
+ CanActivate,
3
+ ExecutionContext,
4
+ Injectable,
5
+ UnauthorizedException,
6
+ } from '@nestjs/common';
7
+ import { JwtService } from '@nestjs/jwt';
8
+ import { PrismaClient } from '@prisma/client';
9
+ import { Request } from 'express';
10
+ import { IncomingHttpHeaders } from 'http';
11
+
12
+ @Injectable()
13
+ export class AuthGuard implements CanActivate {
14
+ private prisma: PrismaClient;
15
+
16
+ constructor(
17
+ private jwtService: JwtService,
18
+ ) {
19
+ this.prisma = new PrismaClient();
20
+ }
21
+
22
+ async canActivate(context: ExecutionContext): Promise<boolean> {
23
+ const request = context.switchToHttp().getRequest();
24
+ const token = this.extractTokenFromHeader(request);
25
+ if (!token) {
26
+ throw new UnauthorizedException();
27
+ }
28
+ try {
29
+ const payload = (await this.jwtService.verifyAsync(token)) as {
30
+ userId: string;
31
+ };
32
+
33
+ const user = await this.prisma.user.findUnique({
34
+ where: { id: payload.userId }
35
+ });
36
+
37
+ if (!user) {
38
+ throw new UnauthorizedException();
39
+ }
40
+
41
+ request['user'] = user;
42
+ } catch {
43
+ throw new UnauthorizedException();
44
+ }
45
+ return true;
46
+ }
47
+
48
+ private extractTokenFromHeader(request: Request & { headers: IncomingHttpHeaders }): string | undefined {
49
+ const [type, token] = request.headers.authorization?.split(' ') ?? [];
50
+ return type === 'Bearer' ? token : undefined;
51
+ }
52
+ }
53
+
54
+ @Injectable()
55
+ export class OptionalAuthGuard implements CanActivate {
56
+ private prisma: PrismaClient;
57
+
58
+ constructor(
59
+ private jwtService: JwtService,
60
+ ) {
61
+ this.prisma = new PrismaClient();
62
+ }
63
+
64
+ async canActivate(context: ExecutionContext): Promise<boolean> {
65
+ const request = context.switchToHttp().getRequest();
66
+ const token = this.extractTokenFromHeader(request);
67
+ if (!token) {
68
+ return true;
69
+ }
70
+ try {
71
+ const payload = (await this.jwtService.verifyAsync(token)) as {
72
+ userId: string;
73
+ };
74
+
75
+ const user = await this.prisma.user.findUnique({
76
+ where: { id: payload.userId }
77
+ });
78
+
79
+ if (!user) {
80
+ throw new UnauthorizedException();
81
+ }
82
+
83
+ request['user'] = user;
84
+
85
+ // Continue without setting user
86
+ } catch {
87
+ // Continue without setting user
88
+ }
89
+ return true;
90
+ }
91
+
92
+ private extractTokenFromHeader(request: Request & { headers: IncomingHttpHeaders }): string | undefined {
93
+ const [type, token] = request.headers.authorization?.split(' ') ?? [];
94
+ return type === 'Bearer' ? token : undefined;
95
+ }
96
+ }
@@ -1,24 +1,24 @@
1
- import { Module, DynamicModule, Global } from '@nestjs/common';
2
- import { JwtModule } from '@nestjs/jwt';
3
-
4
- export interface AuthModuleOptions {
5
- jwtSecret: string;
6
- jwtExpiresIn?: string | number;
7
- }
8
-
9
- @Global()
10
- @Module({})
11
- export class AuthModule {
12
- static forRoot(options: AuthModuleOptions): DynamicModule {
13
- return {
14
- module: AuthModule,
15
- imports: [
16
- JwtModule.register({
17
- secret: options.jwtSecret,
18
- signOptions: { expiresIn: options.jwtExpiresIn || '7d' },
19
- }),
20
- ],
21
- exports: [JwtModule],
22
- };
23
- }
24
- }
1
+ import { Module, DynamicModule, Global } from '@nestjs/common';
2
+ import { JwtModule } from '@nestjs/jwt';
3
+
4
+ export interface AuthModuleOptions {
5
+ jwtSecret: string;
6
+ jwtExpiresIn?: string | number;
7
+ }
8
+
9
+ @Global()
10
+ @Module({})
11
+ export class AuthModule {
12
+ static forRoot(options: AuthModuleOptions): DynamicModule {
13
+ return {
14
+ module: AuthModule,
15
+ imports: [
16
+ JwtModule.register({
17
+ secret: options.jwtSecret,
18
+ signOptions: { expiresIn: options.jwtExpiresIn || '7d' },
19
+ }),
20
+ ],
21
+ exports: [JwtModule],
22
+ };
23
+ }
24
+ }
@@ -1,25 +1,25 @@
1
- import { Module, DynamicModule, Global } from '@nestjs/common';
2
- import { Cacheable } from 'cacheable';
3
- import { CacheService } from './cache.service';
4
- import KeyvRedis from '@keyv/redis';
5
-
6
- @Global()
7
- @Module({})
8
- export class CacheModule {
9
- static forRoot(redisUrl: string): DynamicModule {
10
- return {
11
- module: CacheModule,
12
- providers: [
13
- {
14
- provide: 'CACHE_INSTANCE',
15
- useFactory: () => {
16
- const secondary = new KeyvRedis(redisUrl);
17
- return new Cacheable({ secondary, ttl: '1h' });
18
- },
19
- },
20
- CacheService,
21
- ],
22
- exports: ['CACHE_INSTANCE', CacheService],
23
- };
24
- }
25
- }
1
+ import { Module, DynamicModule, Global } from '@nestjs/common';
2
+ import { Cacheable } from 'cacheable';
3
+ import { CacheService } from './cache.service';
4
+ import KeyvRedis from '@keyv/redis';
5
+
6
+ @Global()
7
+ @Module({})
8
+ export class CacheModule {
9
+ static forRoot(redisUrl: string): DynamicModule {
10
+ return {
11
+ module: CacheModule,
12
+ providers: [
13
+ {
14
+ provide: 'CACHE_INSTANCE',
15
+ useFactory: () => {
16
+ const secondary = new KeyvRedis(redisUrl);
17
+ return new Cacheable({ secondary, ttl: '1h' });
18
+ },
19
+ },
20
+ CacheService,
21
+ ],
22
+ exports: ['CACHE_INSTANCE', CacheService],
23
+ };
24
+ }
25
+ }
@@ -1,19 +1,19 @@
1
- import { Inject, Injectable } from '@nestjs/common';
2
- import { Cacheable } from 'cacheable';
3
-
4
- @Injectable()
5
- export class CacheService<T> {
6
- constructor(@Inject('CACHE_INSTANCE') private readonly cache: Cacheable) {}
7
-
8
- async get<T>(key: string): Promise<T> {
9
- return await this.cache.get(key);
10
- }
11
-
12
- async set(key: string, value: T, ttl?: number | string): Promise<void> {
13
- await this.cache.set(key, value, ttl);
14
- }
15
-
16
- async delete(key: string): Promise<void> {
17
- await this.cache.delete(key);
18
- }
19
- }
1
+ import { Inject, Injectable } from '@nestjs/common';
2
+ import { Cacheable } from 'cacheable';
3
+
4
+ @Injectable()
5
+ export class CacheService<T> {
6
+ constructor(@Inject('CACHE_INSTANCE') private readonly cache: Cacheable) {}
7
+
8
+ async get<T>(key: string): Promise<T> {
9
+ return await this.cache.get(key);
10
+ }
11
+
12
+ async set(key: string, value: T, ttl?: number | string): Promise<void> {
13
+ await this.cache.set(key, value, ttl);
14
+ }
15
+
16
+ async delete(key: string): Promise<void> {
17
+ await this.cache.delete(key);
18
+ }
19
+ }
package/src/index.ts CHANGED
@@ -1,21 +1,21 @@
1
- export * from './auth/auth.guard';
2
- export { PrismaClient, User, Account, UserRole, Event, EventAccess, EventVisibility, EventStatus, EventPrice, Address } from '@prisma/client';
3
-
4
- //auth
5
- export * from './auth/auth.guard';
6
- export * from './auth/auth.module';
7
-
8
- //cache
9
- export * from './cache/cache.module';
10
- export * from './cache/cache.service';
11
-
12
- //prisma
13
- export * from './prisma/prisma.module';
14
- export * from './prisma/prisma.service';
15
-
16
- export * from './types';
17
- export * from './utils';
18
- export * from './utils/api/endpoints';
19
- export * from './utils/events';
20
-
1
+ export * from './auth/auth.guard';
2
+ export { PrismaClient, User, Account, UserRole, Event, EventAccess, EventVisibility, EventStatus, EventPrice, Address, Participant, ParticipantStatus } from '@prisma/client';
3
+
4
+ //auth
5
+ export * from './auth/auth.guard';
6
+ export * from './auth/auth.module';
7
+
8
+ //cache
9
+ export * from './cache/cache.module';
10
+ export * from './cache/cache.service';
11
+
12
+ //prisma
13
+ export * from './prisma/prisma.module';
14
+ export * from './prisma/prisma.service';
15
+
16
+ export * from './types';
17
+ export * from './utils';
18
+ export * from './utils/api/endpoints';
19
+ export * from './utils/events';
20
+
21
21
  export { JwtService } from "@nestjs/jwt";
@@ -1,9 +1,9 @@
1
- import { Module, Global } from '@nestjs/common';
2
- import { PrismaService } from './prisma.service';
3
-
4
- @Global()
5
- @Module({
6
- providers: [PrismaService],
7
- exports: [PrismaService],
8
- })
9
- export class PrismaModule {}
1
+ import { Module, Global } from '@nestjs/common';
2
+ import { PrismaService } from './prisma.service';
3
+
4
+ @Global()
5
+ @Module({
6
+ providers: [PrismaService],
7
+ exports: [PrismaService],
8
+ })
9
+ export class PrismaModule {}
@@ -1,13 +1,13 @@
1
- import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
2
- import { PrismaClient } from '@prisma/client';
3
-
4
- @Injectable()
5
- export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
6
- async onModuleInit() {
7
- await this.$connect();
8
- }
9
-
10
- async onModuleDestroy() {
11
- await this.$disconnect();
12
- }
13
- }
1
+ import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
2
+ import { PrismaClient } from '@prisma/client';
3
+
4
+ @Injectable()
5
+ export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
6
+ async onModuleInit() {
7
+ await this.$connect();
8
+ }
9
+
10
+ async onModuleDestroy() {
11
+ await this.$disconnect();
12
+ }
13
+ }
@@ -1,12 +1,12 @@
1
- export interface PaginatedData<T> {
2
- items: T[];
3
- total: number;
4
- page: number;
5
- limit: number;
6
- totalPages: number;
7
- }
8
-
9
- export interface PaginationQuery {
10
- page?: string;
11
- limit?: string;
12
- }
1
+ export interface PaginatedData<T> {
2
+ items: T[];
3
+ total: number;
4
+ page: number;
5
+ limit: number;
6
+ totalPages: number;
7
+ }
8
+
9
+ export interface PaginationQuery {
10
+ page?: string;
11
+ limit?: string;
12
+ }
@@ -1,7 +1,7 @@
1
- export const CHAT_API_URL: string = "api/chats"
2
- export const PROPERTIES_API_URL: string = "api/properties"
3
-
4
- export const API_ENDPOINTS = {
5
- CHAT: 'api/chats',
6
- PROPERTIES_API_URL: 'api/properties',
1
+ export const CHAT_API_URL: string = "api/chats"
2
+ export const PROPERTIES_API_URL: string = "api/properties"
3
+
4
+ export const API_ENDPOINTS = {
5
+ CHAT: 'api/chats',
6
+ PROPERTIES_API_URL: 'api/properties',
7
7
  }
@@ -1,13 +1,13 @@
1
- export const DEFAULT_AVATAR_IMAGE =
2
- 'https://immob-bucket-2.s3.us-east-2.amazonaws.com/pictures/images.png';
3
-
4
- export const TEMPORARY_EMAIL_DOMAINS = [
5
- '10minutemail.com',
6
- 'guerrillamail.com',
7
- 'mailinator.com',
8
- 'dispostable.com',
9
- 'yopmail.com',
10
- 'trashmail.com',
11
- 'tempmail.com',
12
- 'temp-mail.org',
13
- ];
1
+ export const DEFAULT_AVATAR_IMAGE =
2
+ 'https://immob-bucket-2.s3.us-east-2.amazonaws.com/pictures/images.png';
3
+
4
+ export const TEMPORARY_EMAIL_DOMAINS = [
5
+ '10minutemail.com',
6
+ 'guerrillamail.com',
7
+ 'mailinator.com',
8
+ 'dispostable.com',
9
+ 'yopmail.com',
10
+ 'trashmail.com',
11
+ 'tempmail.com',
12
+ 'temp-mail.org',
13
+ ];
@@ -1,7 +1,7 @@
1
- export const SOCKET_EVENTS = {
2
- INBOX_OPENED: 'events.sockets.inboxOpened',
3
- INBOX_CHANGED: 'events.sockets.inboxChanged',
4
- NEW_MESSAGE: 'events.sockets.newMessage',
5
- GET_UNREAD_MESSAGES_COUNT: 'events.sockets.getUnreadMessagesCount',
6
- }
7
-
1
+ export const SOCKET_EVENTS = {
2
+ INBOX_OPENED: 'events.sockets.inboxOpened',
3
+ INBOX_CHANGED: 'events.sockets.inboxChanged',
4
+ NEW_MESSAGE: 'events.sockets.newMessage',
5
+ GET_UNREAD_MESSAGES_COUNT: 'events.sockets.getUnreadMessagesCount',
6
+ }
7
+
@@ -1,12 +1,12 @@
1
- import { PaginationQuery } from "@/types";
2
-
3
- export const getPaginationData = (query: PaginationQuery) => {
4
- const page = query.page as string;
5
- const PAGE = parseInt(page, 10) || 1;
6
- const LIMIT = Number(query.limit) || 10;
7
- const SKIP = (PAGE - 1) * LIMIT;
8
-
9
- return { page: PAGE, skip: SKIP, limit: LIMIT };
10
- };
11
-
1
+ import { PaginationQuery } from "@/types";
2
+
3
+ export const getPaginationData = (query: PaginationQuery) => {
4
+ const page = query.page as string;
5
+ const PAGE = parseInt(page, 10) || 1;
6
+ const LIMIT = Number(query.limit) || 10;
7
+ const SKIP = (PAGE - 1) * LIMIT;
8
+
9
+ return { page: PAGE, skip: SKIP, limit: LIMIT };
10
+ };
11
+
12
12
  export const getUserChannel = (userId: string) => `channels-user-${userId}`;