2023-01-12 03:34:36 +01:00
|
|
|
import { DynamicModule, Global, Module, ModuleMetadata, Provider } from '@nestjs/common';
|
2023-01-18 15:40:15 +01:00
|
|
|
import { APIKeyService } from './api-key';
|
2023-01-21 17:11:55 +01:00
|
|
|
import { SystemConfigService } from './system-config';
|
2023-01-12 03:34:36 +01:00
|
|
|
import { UserService } from './user';
|
|
|
|
|
2023-01-21 17:11:55 +01:00
|
|
|
export const INITIAL_SYSTEM_CONFIG = 'INITIAL_SYSTEM_CONFIG';
|
|
|
|
|
2023-01-12 03:34:36 +01:00
|
|
|
const providers: Provider[] = [
|
|
|
|
//
|
2023-01-18 15:40:15 +01:00
|
|
|
APIKeyService,
|
2023-01-21 17:11:55 +01:00
|
|
|
SystemConfigService,
|
2023-01-12 03:34:36 +01:00
|
|
|
UserService,
|
2023-01-21 17:11:55 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
provide: INITIAL_SYSTEM_CONFIG,
|
|
|
|
inject: [SystemConfigService],
|
|
|
|
useFactory: async (configService: SystemConfigService) => {
|
|
|
|
return configService.getConfig();
|
|
|
|
},
|
|
|
|
},
|
2023-01-12 03:34:36 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
@Global()
|
|
|
|
@Module({})
|
|
|
|
export class DomainModule {
|
|
|
|
static register(options: Pick<ModuleMetadata, 'imports'>): DynamicModule {
|
|
|
|
return {
|
|
|
|
module: DomainModule,
|
|
|
|
imports: options.imports,
|
|
|
|
providers: [...providers],
|
|
|
|
exports: [...providers],
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|