import { Module } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';
import { PassportModule } from '@nestjs/passport';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { AuthService } from './auth.service';
import { InvitesService } from './invites.service';
import { JwtStrategy } from './jwt.strategy';
import { AuthController } from './auth.controller';
import { SystemConfigModule } from '../../shared/config/system-config.module';
import { SmsModule } from './sms/sms.module';

@Module({
  imports: [
    SmsModule,
    SystemConfigModule,
    PassportModule.register({ defaultStrategy: 'jwt' }),
    JwtModule.registerAsync({
      imports: [ConfigModule],
      useFactory: (config: ConfigService) => ({
        secret: config.get('JWT_SECRET', 'dev-secret'),
        signOptions: { expiresIn: config.get('JWT_PLAYER_EXPIRES', '24h') },
      }),
      inject: [ConfigService],
    }),
  ],
  providers: [AuthService, InvitesService, JwtStrategy],
  controllers: [AuthController],
  exports: [AuthService, InvitesService, JwtModule],
})
export class AuthModule {}
