forked from lidofinance/ethereum-validators-monitoring
-
Notifications
You must be signed in to change notification settings - Fork 5
/
registry.module.ts
29 lines (26 loc) · 1011 Bytes
/
registry.module.ts
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
import { Module } from '@nestjs/common';
import { ConfigService, ValidatorRegistrySource } from 'common/config';
import { FileSourceModule, FileSourceService } from './file-source';
import { LidoSourceModule, LidoSourceService } from './lido-source';
import { REGISTRY_SOURCE, RegistrySource } from './registry-source.interface';
import { RegistryService } from './registry.service';
@Module({
imports: [LidoSourceModule, FileSourceModule],
providers: [
RegistryService,
{
provide: REGISTRY_SOURCE,
useFactory: async (config: ConfigService, lido: LidoSourceService, file: FileSourceService): Promise<RegistrySource> => {
switch (config.get('VALIDATOR_REGISTRY_SOURCE')) {
case ValidatorRegistrySource.Lido:
return lido;
case ValidatorRegistrySource.File:
return file;
}
},
inject: [ConfigService, LidoSourceService, FileSourceService],
},
],
exports: [RegistryService],
})
export class RegistryModule {}