@optimatech88/titomeet-shared-lib 1.0.26 → 1.0.28
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/dist/auth/admin.middleware.d.ts +11 -0
- package/dist/auth/admin.middleware.d.ts.map +1 -0
- package/dist/auth/admin.middleware.js +26 -0
- package/dist/auth/admin.middleware.js.map +1 -0
- package/dist/auth/auth.guard.d.ts +25 -0
- package/dist/auth/auth.guard.d.ts.map +1 -0
- package/dist/auth/auth.guard.js +133 -0
- package/dist/auth/auth.guard.js.map +1 -0
- package/dist/auth/auth.module.d.ts +9 -0
- package/dist/auth/auth.module.d.ts.map +1 -0
- package/dist/auth/auth.module.js +33 -0
- package/dist/auth/auth.module.js.map +1 -0
- package/dist/cache/cache.module.d.ts +5 -0
- package/dist/cache/cache.module.d.ts.map +1 -0
- package/dist/cache/cache.module.js +41 -0
- package/dist/cache/cache.module.js.map +1 -0
- package/dist/cache/cache.service.d.ts +9 -0
- package/dist/cache/cache.service.d.ts.map +1 -0
- package/dist/cache/cache.service.js +38 -0
- package/dist/cache/cache.service.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/prisma/prisma.module.d.ts +3 -0
- package/dist/prisma/prisma.module.d.ts.map +1 -0
- package/dist/prisma/prisma.module.js +22 -0
- package/dist/prisma/prisma.module.js.map +1 -0
- package/dist/prisma/prisma.service.d.ts +7 -0
- package/dist/prisma/prisma.service.d.ts.map +1 -0
- package/dist/prisma/prisma.service.js +24 -0
- package/dist/prisma/prisma.service.js.map +1 -0
- package/dist/prisma/seed.d.ts +2 -0
- package/dist/prisma/seed.d.ts.map +1 -0
- package/dist/prisma/seed.js +73 -0
- package/dist/prisma/seed.js.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/api/endpoints.d.ts +7 -0
- package/dist/utils/api/endpoints.d.ts.map +1 -0
- package/dist/utils/api/endpoints.js +10 -0
- package/dist/utils/api/endpoints.js.map +1 -0
- package/dist/utils/constants.d.ts +3 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +15 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/events.d.ts +7 -0
- package/dist/utils/events.d.ts.map +1 -0
- package/dist/utils/events.js +10 -0
- package/dist/utils/events.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +14 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +1 -1
- package/prisma/migrations/20250528182042_updated_user_model/migration.sql +11 -0
- package/src/auth/admin.middleware.ts +20 -20
- package/src/auth/auth.guard.ts +154 -154
- package/src/auth/auth.module.ts +25 -25
- package/src/cache/cache.module.ts +25 -25
- package/src/cache/cache.service.ts +19 -19
- package/src/index.ts +42 -40
- package/src/prisma/prisma.module.ts +9 -9
- package/src/prisma/prisma.service.ts +13 -13
- package/src/prisma/seed.ts +82 -82
- 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
|
@@ -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,41 +1,43 @@
|
|
|
1
|
-
export * from './auth/auth.guard';
|
|
2
|
-
export {
|
|
3
|
-
PrismaClient, User, Account,
|
|
4
|
-
UserRole, Event, EventAccess,
|
|
5
|
-
EventVisibility, EventStatus,
|
|
6
|
-
EventPrice, Address,
|
|
7
|
-
Provider,
|
|
8
|
-
ProviderStatus,
|
|
9
|
-
EventCategory,
|
|
10
|
-
Review,
|
|
11
|
-
ProviderCategory,
|
|
12
|
-
Order,
|
|
13
|
-
OrderStatus,
|
|
14
|
-
OrderItem,
|
|
15
|
-
PaymentStatus,
|
|
16
|
-
Chat,
|
|
17
|
-
ChatUser,
|
|
18
|
-
Message,
|
|
19
|
-
Notification,
|
|
20
|
-
NotificationType,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export * from './auth/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export * from './prisma/
|
|
36
|
-
export * from './
|
|
37
|
-
export * from './
|
|
38
|
-
export * from './
|
|
39
|
-
export * from './utils
|
|
40
|
-
|
|
1
|
+
export * from './auth/auth.guard';
|
|
2
|
+
export {
|
|
3
|
+
PrismaClient, User, Account,
|
|
4
|
+
UserRole, Event, EventAccess,
|
|
5
|
+
EventVisibility, EventStatus,
|
|
6
|
+
EventPrice, Address,
|
|
7
|
+
Provider,
|
|
8
|
+
ProviderStatus,
|
|
9
|
+
EventCategory,
|
|
10
|
+
Review,
|
|
11
|
+
ProviderCategory,
|
|
12
|
+
Order,
|
|
13
|
+
OrderStatus,
|
|
14
|
+
OrderItem,
|
|
15
|
+
PaymentStatus,
|
|
16
|
+
Chat,
|
|
17
|
+
ChatUser,
|
|
18
|
+
Message,
|
|
19
|
+
Notification,
|
|
20
|
+
NotificationType,
|
|
21
|
+
MediaType,
|
|
22
|
+
UserStatus,
|
|
23
|
+
} from '@prisma/client';
|
|
24
|
+
|
|
25
|
+
//auth
|
|
26
|
+
export * from './auth/auth.guard';
|
|
27
|
+
export * from './auth/auth.module';
|
|
28
|
+
export * from './auth/admin.middleware';
|
|
29
|
+
|
|
30
|
+
//cache
|
|
31
|
+
export * from './cache/cache.module';
|
|
32
|
+
export * from './cache/cache.service';
|
|
33
|
+
|
|
34
|
+
//prisma
|
|
35
|
+
export * from './prisma/prisma.module';
|
|
36
|
+
export * from './prisma/prisma.service';
|
|
37
|
+
export * from './prisma/seed';
|
|
38
|
+
export * from './types';
|
|
39
|
+
export * from './utils';
|
|
40
|
+
export * from './utils/api/endpoints';
|
|
41
|
+
export * from './utils/events';
|
|
42
|
+
|
|
41
43
|
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/prisma/seed.ts
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
//create a seed for the prisma client
|
|
2
|
-
|
|
3
|
-
import { PrismaClient } from '@prisma/client';
|
|
4
|
-
|
|
5
|
-
const prisma = new PrismaClient();
|
|
6
|
-
|
|
7
|
-
async function main() {
|
|
8
|
-
try {
|
|
9
|
-
const categories = [
|
|
10
|
-
{
|
|
11
|
-
name: 'Music',
|
|
12
|
-
description: 'Music events',
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
name: 'Food',
|
|
16
|
-
description: 'Food events',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
name: 'Art',
|
|
20
|
-
description: 'Art events',
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
name: 'Sports',
|
|
24
|
-
description: 'Sports events',
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
name: 'Games',
|
|
28
|
-
description: 'Games events',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
name: 'Dance',
|
|
32
|
-
description: 'Dance events',
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: 'Fashion',
|
|
36
|
-
description: 'Fashion events',
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: 'Tech',
|
|
40
|
-
description: 'Technology events',
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: 'Science',
|
|
44
|
-
description: 'Science events',
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
];
|
|
48
|
-
|
|
49
|
-
const categoriesCreated = await prisma.eventCategory.findMany({
|
|
50
|
-
where: {
|
|
51
|
-
name: {
|
|
52
|
-
in: categories.map((category) => category.name),
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const categoriesNotCreated = categories.filter((category) => !categoriesCreated.some((c) => c.name === category.name));
|
|
58
|
-
|
|
59
|
-
if(categoriesNotCreated.length > 0) {
|
|
60
|
-
console.log(`Creating ${categoriesNotCreated.length} categories`);
|
|
61
|
-
await prisma.eventCategory.createMany({
|
|
62
|
-
data: categoriesNotCreated,
|
|
63
|
-
});
|
|
64
|
-
console.log(`Created ${categoriesNotCreated.length} categories`);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
} catch (error) {
|
|
69
|
-
console.error(error);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
main()
|
|
76
|
-
.catch((error) => {
|
|
77
|
-
console.error(error);
|
|
78
|
-
process.exit(1);
|
|
79
|
-
})
|
|
80
|
-
.finally(async () => {
|
|
81
|
-
await prisma.$disconnect();
|
|
82
|
-
});
|
|
1
|
+
//create a seed for the prisma client
|
|
2
|
+
|
|
3
|
+
import { PrismaClient } from '@prisma/client';
|
|
4
|
+
|
|
5
|
+
const prisma = new PrismaClient();
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
try {
|
|
9
|
+
const categories = [
|
|
10
|
+
{
|
|
11
|
+
name: 'Music',
|
|
12
|
+
description: 'Music events',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: 'Food',
|
|
16
|
+
description: 'Food events',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'Art',
|
|
20
|
+
description: 'Art events',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'Sports',
|
|
24
|
+
description: 'Sports events',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'Games',
|
|
28
|
+
description: 'Games events',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'Dance',
|
|
32
|
+
description: 'Dance events',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'Fashion',
|
|
36
|
+
description: 'Fashion events',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'Tech',
|
|
40
|
+
description: 'Technology events',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'Science',
|
|
44
|
+
description: 'Science events',
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
const categoriesCreated = await prisma.eventCategory.findMany({
|
|
50
|
+
where: {
|
|
51
|
+
name: {
|
|
52
|
+
in: categories.map((category) => category.name),
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const categoriesNotCreated = categories.filter((category) => !categoriesCreated.some((c) => c.name === category.name));
|
|
58
|
+
|
|
59
|
+
if(categoriesNotCreated.length > 0) {
|
|
60
|
+
console.log(`Creating ${categoriesNotCreated.length} categories`);
|
|
61
|
+
await prisma.eventCategory.createMany({
|
|
62
|
+
data: categoriesNotCreated,
|
|
63
|
+
});
|
|
64
|
+
console.log(`Created ${categoriesNotCreated.length} categories`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error(error);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
main()
|
|
76
|
+
.catch((error) => {
|
|
77
|
+
console.error(error);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
})
|
|
80
|
+
.finally(async () => {
|
|
81
|
+
await prisma.$disconnect();
|
|
82
|
+
});
|
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
|
+
|
package/src/utils/index.ts
CHANGED
|
@@ -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}`;
|
package/tsconfig.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"module": "commonjs",
|
|
4
|
-
"declaration": true,
|
|
5
|
-
"removeComments": true,
|
|
6
|
-
"emitDecoratorMetadata": true,
|
|
7
|
-
"experimentalDecorators": true,
|
|
8
|
-
"target": "ES2017",
|
|
9
|
-
"sourceMap": true,
|
|
10
|
-
"outDir": "./dist",
|
|
11
|
-
"baseUrl": ".",
|
|
12
|
-
"rootDir": "./src",
|
|
13
|
-
"paths": {
|
|
14
|
-
"@/*": ["./src/*"]
|
|
15
|
-
},
|
|
16
|
-
"strict": true,
|
|
17
|
-
"strictNullChecks": false,
|
|
18
|
-
"esModuleInterop": true,
|
|
19
|
-
"declarationMap": true,
|
|
20
|
-
"resolveJsonModule": true,
|
|
21
|
-
},
|
|
22
|
-
"include": ["src/**/*.ts"],
|
|
23
|
-
"exclude": ["node_modules", "dist"]
|
|
24
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"removeComments": true,
|
|
6
|
+
"emitDecoratorMetadata": true,
|
|
7
|
+
"experimentalDecorators": true,
|
|
8
|
+
"target": "ES2017",
|
|
9
|
+
"sourceMap": true,
|
|
10
|
+
"outDir": "./dist",
|
|
11
|
+
"baseUrl": ".",
|
|
12
|
+
"rootDir": "./src",
|
|
13
|
+
"paths": {
|
|
14
|
+
"@/*": ["./src/*"]
|
|
15
|
+
},
|
|
16
|
+
"strict": true,
|
|
17
|
+
"strictNullChecks": false,
|
|
18
|
+
"esModuleInterop": true,
|
|
19
|
+
"declarationMap": true,
|
|
20
|
+
"resolveJsonModule": true,
|
|
21
|
+
},
|
|
22
|
+
"include": ["src/**/*.ts"],
|
|
23
|
+
"exclude": ["node_modules", "dist"]
|
|
24
|
+
}
|