123
This commit is contained in:
@ -15,12 +15,20 @@ import { UsersModule } from '../users/users.module';
|
||||
PassportModule.register({ defaultStrategy: 'jwt' }),
|
||||
JwtModule.registerAsync({
|
||||
imports: [ConfigModule],
|
||||
useFactory: async (configService: ConfigService) => ({
|
||||
secret: configService.get('JWT_SECRET'),
|
||||
signOptions: {
|
||||
expiresIn: '7d',
|
||||
},
|
||||
}),
|
||||
useFactory: async (configService: ConfigService) => {
|
||||
const secret = configService.get<string>('JWT_SECRET');
|
||||
if (!secret || secret.trim() === '') {
|
||||
throw new Error(
|
||||
'JWT_SECRET is not set or empty. Set it in .env and run Docker with: docker compose --env-file .env up -d',
|
||||
);
|
||||
}
|
||||
return {
|
||||
secret: secret.trim(),
|
||||
signOptions: {
|
||||
expiresIn: '7d',
|
||||
},
|
||||
};
|
||||
},
|
||||
inject: [ConfigService],
|
||||
}),
|
||||
UsersModule,
|
||||
|
||||
Reference in New Issue
Block a user