import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import appConfig from 'src/config/app.config';
import databaseConfig from 'src/config/database.config';
import { DataSource } from 'typeorm';
import { TypeOrmConfigService } from '../typeorm-config.service';
import { PlayersSeedModule } from './player/player-seed.module';
import { RoleSeedModule } from './role/role-seed.module';
import { StatusSeedModule } from './status/status-seed.module';
import { TeamRolesSeedModule } from './team-role/team-role-seed.module';
import { TeamSettingsSeedModule } from './team-settings/team-settings-seed.module';
import { TeamWalletTransactionTypeSeedModule } from './team-wallet-transactions-type/team-wallet-transaction-type-seed.module';
import { TeamWalletTransactionSeedModule } from './team-wallet-transactions/team-wallet-transaction-seed.module';
import { TeamsSeedModule } from './teams/teams-seed.module';
import { TransactionsTypeSeedModule } from './transaction-type/transactions-type-seed.module';
import { TransactionsSeedModule } from './transactions/transactions-seed.module';
import { UserSeedModule } from './user/user-seed.module';

@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
      load: [databaseConfig, appConfig],
      envFilePath: ['.env'],
    }),
    TypeOrmModule.forRootAsync({
      useClass: TypeOrmConfigService,
      dataSourceFactory: async (options) => {
        const dataSource = await new DataSource(options).initialize();
        return dataSource;
      },
    }),
    RoleSeedModule,
    StatusSeedModule,
    UserSeedModule,
    TeamRolesSeedModule,
    TeamsSeedModule,
    PlayersSeedModule,
    TransactionsTypeSeedModule,
    TransactionsSeedModule,
    TeamSettingsSeedModule,
    TeamWalletTransactionTypeSeedModule,
    TeamWalletTransactionSeedModule,
  ],
})
export class SeedModule {}
