import { Module } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';
import { ConfigModule, ConfigService } from '@nestjs/config';
import {
  AuthController,
  SmsController,
  PasswordController,
  TradePasswordController,
  KycController,
  UserController,
  HealthController,
  AdminController,
  InternalController,
  CapabilityController,
} from './controllers';
import { ApplicationModule } from '@/application';
import { JwtAuthGuard } from '@/shared/guards/jwt-auth.guard';
import { CapabilityGuard } from '@/shared/guards/capability.guard';

@Module({
  imports: [
    ApplicationModule,
    JwtModule.registerAsync({
      imports: [ConfigModule],
      useFactory: (configService: ConfigService) => ({
        secret: configService.get<string>('JWT_SECRET'),
        signOptions: {
          expiresIn: configService.get<string>('JWT_EXPIRES_IN', '7d'),
        },
      }),
      inject: [ConfigService],
    }),
  ],
  controllers: [
    AuthController,
    SmsController,
    PasswordController,
    TradePasswordController,
    KycController,
    UserController,
    HealthController,
    AdminController,
    InternalController,
    CapabilityController,
  ],
  providers: [JwtAuthGuard, CapabilityGuard],
})
export class ApiModule {}
