26 lines
787 B
TypeScript
26 lines
787 B
TypeScript
import { Module } from '@nestjs/common';
|
|
import { JwtModule } from '@nestjs/jwt';
|
|
import { PassportModule } from '@nestjs/passport';
|
|
import { EnvModule } from '../env/env.module';
|
|
import { EnvService } from '../env/env.service';
|
|
import { JwtAuthGuard } from './jwt-auth.guard';
|
|
import { JwtStrategy } from './jwt.strategy';
|
|
|
|
@Module({
|
|
imports: [
|
|
EnvModule,
|
|
PassportModule.register({ defaultStrategy: 'jwt' }),
|
|
JwtModule.registerAsync({
|
|
imports: [EnvModule],
|
|
inject: [EnvService],
|
|
useFactory: (envService: EnvService) => ({
|
|
secret: envService.jwtSecret,
|
|
signOptions: { expiresIn: '8h' },
|
|
}),
|
|
}),
|
|
],
|
|
providers: [JwtStrategy, JwtAuthGuard],
|
|
exports: [JwtModule, JwtStrategy, JwtAuthGuard],
|
|
})
|
|
export class AuthConfigModule {}
|