import { Module } from '@nestjs/common';

import { GoogleStrategy } from './strategies/google.strategy';
import { PassportModule } from '@nestjs/passport';
import { JwtModule } from '@nestjs/jwt';
import { HeaderApiKeyStrategy } from './strategies/api-key.strategy';
import { JwtStrategy } from './strategies/jwt.strategy';
import { AppConfigModule } from 'src/config/app/app-config.module';
import { RedisModule } from 'src/cache/cache.module';
import { AuthService } from './auth.service';
import { AppConfigService } from 'src/config/app/app-config.service';
import { AuthController } from './auth.controller';
import { PrismaModule } from 'src/prisma/prisma.module';
import { PrismaService } from 'src/prisma/prisma.service';
import { MailModule } from 'src/share/mail/mail.module';
import { MailService } from 'src/share/mail/mail.service';
// import { PrismaModule, PrismaService } from 'nestjs-prisma';

@Module({
  imports: [
    AppConfigModule,
    PassportModule.register({ defaultStrategy: 'jwt' }),
    JwtModule.registerAsync({
      inject: [AppConfigService],
      imports: [AppConfigModule],
      useFactory: (cf: AppConfigService) => {
        return {
          secret: cf.jwtAccessSecret,
          signOptions: {
            expiresIn: cf.jwtExpiresIn,
          },
        };
      },
    }),
    RedisModule,
    PrismaModule,
    MailModule,
  ],
  controllers: [AuthController],
  providers: [
    AppConfigService,
    GoogleStrategy,
    HeaderApiKeyStrategy,
    JwtStrategy,
    AuthService,
    PrismaService,
    MailService,
  ],
})
export class AuthModule {}
