-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Expand file tree
/
Copy pathshared.module.ts
More file actions
62 lines (54 loc) · 1.52 KB
/
shared.module.ts
File metadata and controls
62 lines (54 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { Module } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';
import {
AnalyticsService,
DalServiceHealthIndicator,
featureFlagsService,
LogLevelService,
QueuesModule,
WebSocketsInMemoryProviderService,
} from '@novu/application-generic';
import { DalService, MessageRepository, NotificationRepository, SubscriberRepository } from '@novu/dal';
import { JobTopicNameEnum } from '@novu/shared';
import { SubscriberOnlineService } from './subscriber-online';
const DAL_MODELS = [SubscriberRepository, NotificationRepository, MessageRepository];
const dalService = {
provide: DalService,
useFactory: async () => {
const service = new DalService();
await service.connect(String(process.env.MONGO_URL));
return service;
},
};
const analyticsService = {
provide: AnalyticsService,
useFactory: async () => {
const service = new AnalyticsService(process.env.SEGMENT_TOKEN, 500);
await service.initialize();
return service;
},
};
const PROVIDERS = [
analyticsService,
dalService,
DalServiceHealthIndicator,
featureFlagsService,
LogLevelService,
SubscriberOnlineService,
WebSocketsInMemoryProviderService,
...DAL_MODELS,
];
@Module({
imports: [
QueuesModule.forRoot([JobTopicNameEnum.WEB_SOCKETS]),
JwtModule.register({
secretOrKeyProvider: () => process.env.JWT_SECRET as string,
signOptions: {
expiresIn: 360000,
},
}),
],
providers: [...PROVIDERS],
exports: [...PROVIDERS, JwtModule, QueuesModule],
})
export class SharedModule {}