import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';

import { ConfigModule } from '@nestjs/config';
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { OtpVerificationModel } from './data/models/otp-verification.model';
import {
  OtpVerificationController,
  OtpVerifierController,
} from './infrastructure/otp-verification-data.controller';
import { OtpVerificationService } from './data/services/otp-verification.service';
import { OtpVerifierModel } from './data/models/otp-verifier.model';
import { OtpAuthGuard } from './infrastructure/guards/otp-auth.guard';

import { JwtModule } from '@nestjs/jwt';
import { JWT_EXPIRED } from 'src/core/sessions/constants';
import { JWT_SECRET } from 'src/core/sessions/constants';
import { OtpVerifierService } from './data/services/otp-verifier.service';

@Module({
  imports: [
    ConfigModule.forRoot(),

    TypeOrmModule.forFeature(
      [OtpVerificationModel, OtpVerifierModel],
      CONNECTION_NAME.DEFAULT,
    ),

    JwtModule.register({
      secret: JWT_SECRET,
      signOptions: { expiresIn: JWT_EXPIRED },
    }),
  ],
  controllers: [OtpVerificationController, OtpVerifierController],
  providers: [OtpAuthGuard, OtpVerificationService, OtpVerifierService],
})
export class OtpVerificationModule {}
