@optimatech88/titomeet-shared-lib 1.0.5 → 1.0.6
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/.github/workflows/npm-publish.yml +34 -34
- package/.prettierrc +4 -4
- package/package.json +4 -2
- package/prisma/schema.prisma +26 -0
- package/src/auth/auth.guard.ts +96 -96
- package/src/auth/auth.module.ts +24 -24
- package/src/cache/cache.module.ts +25 -25
- package/src/cache/cache.service.ts +19 -19
- package/src/index.ts +27 -20
- package/src/prisma/prisma.module.ts +9 -9
- package/src/prisma/prisma.service.ts +13 -13
- package/src/types/index.ts +12 -12
- package/src/utils/api/endpoints.ts +6 -6
- package/src/utils/constants.ts +13 -13
- package/src/utils/events.ts +7 -7
- package/src/utils/index.ts +11 -11
- package/tsconfig.json +24 -24
- package/dist/auth/auth.guard.d.ts +0 -17
- package/dist/auth/auth.guard.d.ts.map +0 -1
- package/dist/auth/auth.guard.js +0 -89
- package/dist/auth/auth.guard.js.map +0 -1
- package/dist/auth/auth.module.d.ts +0 -9
- package/dist/auth/auth.module.d.ts.map +0 -1
- package/dist/auth/auth.module.js +0 -32
- package/dist/auth/auth.module.js.map +0 -1
- package/dist/cache/cache.module.d.ts +0 -5
- package/dist/cache/cache.module.d.ts.map +0 -1
- package/dist/cache/cache.module.js +0 -41
- package/dist/cache/cache.module.js.map +0 -1
- package/dist/cache/cache.service.d.ts +0 -9
- package/dist/cache/cache.service.d.ts.map +0 -1
- package/dist/cache/cache.service.js +0 -38
- package/dist/cache/cache.service.js.map +0 -1
- package/dist/index.d.ts +0 -14
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -38
- package/dist/index.js.map +0 -1
- package/dist/prisma/prisma.module.d.ts +0 -3
- package/dist/prisma/prisma.module.d.ts.map +0 -1
- package/dist/prisma/prisma.module.js +0 -22
- package/dist/prisma/prisma.module.js.map +0 -1
- package/dist/prisma/prisma.service.d.ts +0 -7
- package/dist/prisma/prisma.service.d.ts.map +0 -1
- package/dist/prisma/prisma.service.js +0 -24
- package/dist/prisma/prisma.service.js.map +0 -1
- package/dist/prisma/prisma.service.spec.d.ts +0 -2
- package/dist/prisma/prisma.service.spec.d.ts.map +0 -1
- package/dist/prisma/prisma.service.spec.js +0 -17
- package/dist/prisma/prisma.service.spec.js.map +0 -1
- package/dist/types/index.d.ts +0 -12
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -3
- package/dist/types/index.js.map +0 -1
- package/dist/utils/api/endpoints.d.ts +0 -7
- package/dist/utils/api/endpoints.d.ts.map +0 -1
- package/dist/utils/api/endpoints.js +0 -10
- package/dist/utils/api/endpoints.js.map +0 -1
- package/dist/utils/constants.d.ts +0 -3
- package/dist/utils/constants.d.ts.map +0 -1
- package/dist/utils/constants.js +0 -15
- package/dist/utils/constants.js.map +0 -1
- package/dist/utils/events.d.ts +0 -7
- package/dist/utils/events.d.ts.map +0 -1
- package/dist/utils/events.js +0 -10
- package/dist/utils/events.js.map +0 -1
- package/dist/utils/index.d.ts +0 -8
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -14
- package/dist/utils/index.js.map +0 -1
|
@@ -1,34 +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
|
-
|
|
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}}
|
|
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 run build
|
|
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 --access public
|
|
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,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optimatech88/titomeet-shared-lib",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
8
|
"build": "nest build",
|
|
9
|
-
"format": "prettier --write \"src/**/*.ts\""
|
|
9
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
10
|
+
"generate": "npx prisma generate"
|
|
10
11
|
},
|
|
11
12
|
"keywords": [],
|
|
12
13
|
"author": "",
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
"nestjs-seeder": "^0.3.2"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
35
|
+
"@nestjs/cli": "^11.0.5",
|
|
34
36
|
"@types/express": "^4.17.21",
|
|
35
37
|
"@types/node": "^22.2.0",
|
|
36
38
|
"prettier": "^3.3.3",
|
package/prisma/schema.prisma
CHANGED
|
@@ -40,6 +40,7 @@ model User {
|
|
|
40
40
|
participatedEvents Participant[]
|
|
41
41
|
notificationsReceived Notification[] @relation("NotificationRecipient")
|
|
42
42
|
notificationsSent Notification[] @relation("NotificationSender")
|
|
43
|
+
providers Provider[]
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
model Account {
|
|
@@ -107,6 +108,8 @@ model Event {
|
|
|
107
108
|
// Add participants relation
|
|
108
109
|
participants Participant[]
|
|
109
110
|
|
|
111
|
+
providers Provider[]
|
|
112
|
+
|
|
110
113
|
createdAt DateTime @default(now())
|
|
111
114
|
updatedAt DateTime @updatedAt
|
|
112
115
|
}
|
|
@@ -183,6 +186,29 @@ model Notification {
|
|
|
183
186
|
read Boolean @default(false)
|
|
184
187
|
data Json?
|
|
185
188
|
|
|
189
|
+
createdAt DateTime @default(now())
|
|
190
|
+
updatedAt DateTime @updatedAt
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
enum ProviderStatus {
|
|
194
|
+
PENDING
|
|
195
|
+
APPROVED
|
|
196
|
+
REJECTED
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
model Provider {
|
|
200
|
+
id String @id @default(cuid())
|
|
201
|
+
name String
|
|
202
|
+
description String?
|
|
203
|
+
image String?
|
|
204
|
+
|
|
205
|
+
user User @relation(fields: [userId], references: [id])
|
|
206
|
+
userId String
|
|
207
|
+
|
|
208
|
+
events Event[]
|
|
209
|
+
|
|
210
|
+
status ProviderStatus @default(PENDING)
|
|
211
|
+
|
|
186
212
|
createdAt DateTime @default(now())
|
|
187
213
|
updatedAt DateTime @updatedAt
|
|
188
214
|
}
|
package/src/auth/auth.guard.ts
CHANGED
|
@@ -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
|
+
}
|
package/src/auth/auth.module.ts
CHANGED
|
@@ -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,28 @@
|
|
|
1
|
-
export * from './auth/auth.guard';
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export * from './
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export * from './
|
|
17
|
-
export * from './
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
export * from './auth/auth.guard';
|
|
2
|
+
export {
|
|
3
|
+
PrismaClient, User, Account,
|
|
4
|
+
UserRole, Event, EventAccess,
|
|
5
|
+
EventVisibility, EventStatus,
|
|
6
|
+
EventPrice, Address, Participant,
|
|
7
|
+
ParticipantStatus,
|
|
8
|
+
Provider,
|
|
9
|
+
ProviderStatus } from '@prisma/client';
|
|
10
|
+
|
|
11
|
+
//auth
|
|
12
|
+
export * from './auth/auth.guard';
|
|
13
|
+
export * from './auth/auth.module';
|
|
14
|
+
|
|
15
|
+
//cache
|
|
16
|
+
export * from './cache/cache.module';
|
|
17
|
+
export * from './cache/cache.service';
|
|
18
|
+
|
|
19
|
+
//prisma
|
|
20
|
+
export * from './prisma/prisma.module';
|
|
21
|
+
export * from './prisma/prisma.service';
|
|
22
|
+
|
|
23
|
+
export * from './types';
|
|
24
|
+
export * from './utils';
|
|
25
|
+
export * from './utils/api/endpoints';
|
|
26
|
+
export * from './utils/events';
|
|
27
|
+
|
|
21
28
|
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
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -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
|
}
|
package/src/utils/constants.ts
CHANGED
|
@@ -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
|
+
];
|
package/src/utils/events.ts
CHANGED
|
@@ -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
|
+
|