import { Module, Global } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { HttpModule } from '@nestjs/axios';
import {
  PrismaService,
  ReferralRelationshipRepository,
  TeamStatisticsRepository,
  KafkaService,
  EventPublisherService,
  RedisService,
  EventAckPublisher,
  AuthorizationServiceClient,
  WalletServiceClient,
} from '../infrastructure';
import {
  REFERRAL_RELATIONSHIP_REPOSITORY,
  TEAM_STATISTICS_REPOSITORY,
} from '../domain';

@Global()
@Module({
  imports: [ConfigModule, HttpModule],
  providers: [
    PrismaService,
    KafkaService,
    RedisService,
    EventPublisherService,
    EventAckPublisher,
    AuthorizationServiceClient,
    WalletServiceClient,
    {
      provide: REFERRAL_RELATIONSHIP_REPOSITORY,
      useClass: ReferralRelationshipRepository,
    },
    {
      provide: TEAM_STATISTICS_REPOSITORY,
      useClass: TeamStatisticsRepository,
    },
  ],
  exports: [
    PrismaService,
    KafkaService,
    RedisService,
    EventPublisherService,
    EventAckPublisher,
    AuthorizationServiceClient,
    WalletServiceClient,
    REFERRAL_RELATIONSHIP_REPOSITORY,
    TEAM_STATISTICS_REPOSITORY,
  ],
})
export class InfrastructureModule {}
