22 lines
581 B
TypeScript
22 lines
581 B
TypeScript
|
|
import { Module, Global } from '@nestjs/common';
|
||
|
|
import { JwtModule } from '@nestjs/jwt';
|
||
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||
|
|
|
||
|
|
@Global()
|
||
|
|
@Module({
|
||
|
|
imports: [
|
||
|
|
JwtModule.registerAsync({
|
||
|
|
imports: [ConfigModule],
|
||
|
|
useFactory: async (configService: ConfigService) => ({
|
||
|
|
secret: configService.get('JWT_SECRET', 'change_me'),
|
||
|
|
signOptions: {
|
||
|
|
expiresIn: configService.get('JWT_EXPIRES_IN', '7d'),
|
||
|
|
},
|
||
|
|
}),
|
||
|
|
inject: [ConfigService],
|
||
|
|
}),
|
||
|
|
],
|
||
|
|
exports: [JwtModule],
|
||
|
|
})
|
||
|
|
export class JwtGlobalModule {}
|