import { Module } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { ScheduleModule } from '@nestjs/schedule';
import {
  AuthService,
  PasswordService,
  TradePasswordService,
  SmsService,
  KycService,
  UserService,
  OutboxService,
  AdminSyncService,
  CapabilityService,
} from './services';
import { OutboxScheduler, CapabilityExpiryScheduler } from './schedulers';
import { InfrastructureModule } from '@/infrastructure/infrastructure.module';

@Module({
  imports: [
    InfrastructureModule,
    ScheduleModule.forRoot(),
    JwtModule.registerAsync({
      imports: [ConfigModule],
      useFactory: (configService: ConfigService) => ({
        secret: configService.get<string>('JWT_SECRET'),
        signOptions: {
          expiresIn: configService.get<string>('JWT_EXPIRES_IN', '7d'),
        },
      }),
      inject: [ConfigService],
    }),
  ],
  providers: [
    AuthService,
    PasswordService,
    TradePasswordService,
    SmsService,
    KycService,
    UserService,
    OutboxService,
    AdminSyncService,
    CapabilityService,
    OutboxScheduler,
    CapabilityExpiryScheduler,
  ],
  exports: [
    AuthService,
    PasswordService,
    TradePasswordService,
    SmsService,
    KycService,
    UserService,
    AdminSyncService,
    OutboxService,
    CapabilityService,
  ],
})
export class ApplicationModule {}
