35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
import { JwtModule } from '@nestjs/jwt';
|
|
import { PassportModule } from '@nestjs/passport';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
|
|
import { AuthController } from './auth.controller';
|
|
import { AuthService } from './auth.service';
|
|
import { JwtStrategy } from './strategies/jwt.strategy';
|
|
import { UsersModule } from '../users/users.module';
|
|
import { Otp } from './entities/otp.entity';
|
|
import { RefreshToken } from './entities/refresh-token.entity';
|
|
|
|
@Module({
|
|
imports: [
|
|
UsersModule,
|
|
TypeOrmModule.forFeature([Otp, RefreshToken]),
|
|
PassportModule.register({ defaultStrategy: 'jwt' }),
|
|
JwtModule.registerAsync({
|
|
imports: [ConfigModule],
|
|
useFactory: async (configService: ConfigService) => ({
|
|
secret: configService.get('JWT_SECRET', 'your-secret-key'),
|
|
signOptions: {
|
|
expiresIn: configService.get('JWT_EXPIRES_IN', '15m'),
|
|
},
|
|
}),
|
|
inject: [ConfigService],
|
|
}),
|
|
],
|
|
controllers: [AuthController],
|
|
providers: [AuthService, JwtStrategy],
|
|
exports: [AuthService, JwtModule],
|
|
})
|
|
export class AuthModule {}
|