import { Module } from '@nestjs/common';
import { CqrsModule } from '@nestjs/cqrs';
import { SearchModule } from '@modules/search';
import { CreateTransferListingHandler } from './application/commands/create-transfer-listing/create-transfer-listing.handler';
import { EstimateTransferPricesHandler } from './application/commands/estimate-transfer-prices/estimate-transfer-prices.handler';
import { UpdateTransferListingHandler } from './application/commands/update-transfer-listing/update-transfer-listing.handler';
import { GetTransferListingHandler } from './application/queries/get-transfer-listing/get-transfer-listing.handler';
import { ListTransferListingsHandler } from './application/queries/list-transfer-listings/list-transfer-listings.handler';
import { TransferStatsHandler } from './application/queries/transfer-stats/transfer-stats.handler';
import { TRANSFER_LISTING_REPOSITORY } from './domain/repositories/transfer-listing.repository';
import { PrismaTransferListingRepository } from './infrastructure/repositories/prisma-transfer-listing.repository';
import { TypesenseTransferService } from './infrastructure/services/typesense-transfer.service';
import { TransferController } from './presentation/controllers/transfer.controller';

const CommandHandlers = [
  CreateTransferListingHandler,
  EstimateTransferPricesHandler,
  UpdateTransferListingHandler,
];

const QueryHandlers = [
  GetTransferListingHandler,
  ListTransferListingsHandler,
  TransferStatsHandler,
];

@Module({
  imports: [CqrsModule, SearchModule],
  controllers: [TransferController],
  providers: [
    { provide: TRANSFER_LISTING_REPOSITORY, useClass: PrismaTransferListingRepository },
    TypesenseTransferService,
    ...CommandHandlers,
    ...QueryHandlers,
  ],
  exports: [TRANSFER_LISTING_REPOSITORY, TypesenseTransferService],
})
export class TransferModule {}
