import { Module } from '@nestjs/common';
import { PassportModule } from '@nestjs/passport';
import { JwtModule } from '@nestjs/jwt';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { HealthController } from './controllers/health.controller';
import { RewardController } from './controllers/reward.controller';
import { SettlementController } from './controllers/settlement.controller';
import { InternalController } from './controllers/internal.controller';
import { JwtStrategy } from '../shared/strategies/jwt.strategy';
import { ApplicationModule } from '../application/application.module';

@Module({
  imports: [
    PassportModule,
    JwtModule.registerAsync({
      imports: [ConfigModule],
      useFactory: (configService: ConfigService) => ({
        secret: configService.get<string>('JWT_SECRET'),
        signOptions: {
          expiresIn: configService.get<string>('JWT_ACCESS_EXPIRES_IN', '2h') as any,
        },
      }),
      inject: [ConfigService],
    }),
    ApplicationModule,
  ],
  controllers: [HealthController, RewardController, SettlementController, InternalController],
  providers: [JwtStrategy],
})
export class ApiModule {}
