import {AuthService} from '../auth/auth.service'; import {AuthModule} from '../auth/auth.module'; import {AuthCron} from './auth.cron'; import {CloudService} from './cloud.service'; import {DbModule} from '../db/db.module'; import {SocketModule} from '../socket/socket.module'; import {HttpModule, Module} from '@nestjs/common'; import {ConfigModule, ConfigService} from '@nestjs/config'; import {ScheduleModule} from '@nestjs/schedule'; import {Store} from "../store"; @Module({ imports: [ ConfigModule.forRoot(), SocketModule, AuthModule, DbModule, HttpModule.registerAsync({ imports: [ConfigModule, AuthModule], useFactory: (config: ConfigService, authService: AuthService) => { return authService.login().then(() => { return { baseURL: config.get('CLOUD_ENDPOINT'), headers: { Authorization: `Bearer ${authService.store.accessToken}` }, }; }); }, inject: [ConfigService, AuthService, Store] }), ScheduleModule.forRoot() ], providers: [ CloudService, AuthCron ], exports: [ CloudService, ] }) export class CloudModule { }