Trần Viết Sơn
Revert "Revert "Feature/update user""
8b6297d unverified
raw
history blame
1.39 kB
import { Module } from '@nestjs/common';
import { AuthenticationService } from './authentication.service.js';
import { UserModule } from '../user/user.module.js';
import { JwtModule } from '@nestjs/jwt';
import { AuthenticationController } from './authentication.controller.js';
import { AuthenticationGuard } from './authentication.guard.js';
import { APP_GUARD } from '@nestjs/core';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { RolesGuard } from './authorization/roles.guard.js';
import { ValidateService } from '../../validate/validate.service.js';
@Module({
imports: [
UserModule,
JwtModule.registerAsync({
imports: [ConfigModule], // Nhập ConfigModule để sử dụng ConfigService
useFactory: async (configService: ConfigService) => ({
secret: configService.get<string>('JWT_KEY'), // Lấy giá trị từ biến môi trường
signOptions: { expiresIn: '7d' }, // Thời gian hết hạn token
}),
inject: [ConfigService], // Inject ConfigService vào factory
}),
],
providers: [
AuthenticationService,
{
provide: APP_GUARD,
useClass: AuthenticationGuard,
},
{
provide: APP_GUARD,
useClass: RolesGuard,
},
ValidateService
],
controllers: [AuthenticationController],
exports: [AuthenticationService],
})
export class AuthenticationModule {}