This commit is contained in:
2026-02-06 11:52:30 +03:00
parent 1812de0baf
commit fd7bf76abd
4 changed files with 289 additions and 6 deletions

View File

@ -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,