import { forwardRef, Global, Module } from '@nestjs/common';
import { SharedService } from './shared.service';
import { AppModule } from '../app.module';
import { GameModule } from '../game/game.module';
import { MongooseModule } from '@nestjs/mongoose';
import { Config, ConfigSchema } from '../schemas/config.schema';
import { ClientProxyFactory, Transport } from '@nestjs/microservices';
import * as process from "process";
import {ConfigModule} from "@nestjs/config";
import {CqrsModule} from "@nestjs/cqrs";
import {FeatureflagService} from "../featureflag/featureflag.service";
@Global()
@Module({
  imports: [
    forwardRef(() => AppModule),
    CqrsModule,
    ConfigModule,
    GameModule,
    MongooseModule.forFeature([{ name: Config.name, schema: ConfigSchema }]),
  ],
  providers: [SharedService,FeatureflagService, {
    provide: 'Telegram',
    useFactory: () =>
      ClientProxyFactory.create({
        transport: Transport.RMQ,
        options: {
          urls: [process.env.RMQ_URL],
          queue: process.env.RMQ_COMMANDS_OUTPUT_Q,
          queueOptions: {
            durable: false,
          },
        },
      }),
  }],
  exports: [SharedService, 'Telegram',FeatureflagService],
})
export class SharedModule {
  constructor() {
  }
}
