import { Module } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { ScheduleModule } from '@nestjs/schedule';
import {
  AuthService,
  PasswordService,
  SmsService,
  KycService,
  UserService,
  OutboxService,
} from './services';
import { OutboxScheduler } 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,
    SmsService,
    KycService,
    UserService,
    OutboxService,
    OutboxScheduler,
  ],
  exports: [
    AuthService,
    PasswordService,
    SmsService,
    KycService,
    UserService,
  ],
})
export class ApplicationModule {}
