import { UsersRepository } from '../admin/access/users/users.repository' ; import { ConfigModule , ConfigService } from '@nestjs/config' ; import { JwtAuthGuard , PermissionsGuard } from './guards' ; import { TokenService , AuthService } from './services' ; import { AuthController } from './auth.controller' ; import { PassportModule } from '@nestjs/passport' ; import { TypeOrmModule } from '@nestjs/typeorm' ; import { JwtStrategy } from './jwt.strategy' ; import { APP_GUARD } from '@nestjs/core' ; import { Module } from '@nestjs/common' ; import { JwtModule } from '@nestjs/jwt' ; @ Module ( { imports : [ ConfigModule , TypeOrmModule . forFeature ( [ UsersRepository ] ) , PassportModule . register ( { defaultStrategy : 'jwt' , } ) , JwtModule . registerAsync ( { imports : [ ConfigModule ] , useFactory : ( config ) => ( { secret : config . get ( 'TOKEN_SECRET' ) , signOptions : { expiresIn : config . get ( 'ACCESS_TOKEN_EXPIRES_IN' ) , } , } ) , inject : [ ConfigService ] , } ) , ] , controllers : [ AuthController ] , providers : [ AuthService , JwtStrategy , TokenService , { provide : APP_GUARD , useClass : JwtAuthGuard , } , { provide : APP_GUARD , useClass : PermissionsGuard , } , ] , exports : [ JwtStrategy , PassportModule , TokenService , AuthService ] , } ) export class AuthModule { }