import { Module } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { MulterModule } from '@nestjs/platform-express';
import { memoryStorage } from 'multer';

// Controllers
import { BattleController } from './battle.controller';
import { BattleMapsController } from './battle-maps.controller';
import { CombatantsController } from './combatants.controller';

// Services
import { BattleService } from './battle.service';
import { BattleMapsService } from './battle-maps.service';
import { CombatantsService } from './combatants.service';

// Gateway
import { BattleGateway } from './battle.gateway';

@Module({
  imports: [
    JwtModule.registerAsync({
      imports: [ConfigModule],
      useFactory: async (configService: ConfigService) => ({
        secret: configService.get<string>('JWT_SECRET'),
      }),
      inject: [ConfigService],
    }),
    MulterModule.register({
      storage: memoryStorage(),
    }),
  ],
  controllers: [
    BattleController,
    BattleMapsController,
    CombatantsController,
  ],
  providers: [
    BattleService,
    BattleMapsService,
    CombatantsService,
    BattleGateway,
  ],
  exports: [
    BattleService,
    BattleMapsService,
    CombatantsService,
    BattleGateway,
  ],
})
export class BattleModule {}
