mirror of https://github.com/ghostfolio/ghostfolio
9 changed files with 102 additions and 30 deletions
@ -0,0 +1,21 @@ |
|||||
|
import { ExecutionContext, Injectable, Logger } from '@nestjs/common'; |
||||
|
import { ThrottlerException, ThrottlerGuard } from '@nestjs/throttler'; |
||||
|
|
||||
|
@Injectable() |
||||
|
export class CustomThrottlerGuard extends ThrottlerGuard { |
||||
|
private readonly logger = new Logger(CustomThrottlerGuard.name); |
||||
|
|
||||
|
public async canActivate(context: ExecutionContext): Promise<boolean> { |
||||
|
try { |
||||
|
return await super.canActivate(context); |
||||
|
} catch (error) { |
||||
|
if (error instanceof ThrottlerException) { |
||||
|
throw error; |
||||
|
} |
||||
|
|
||||
|
this.logger.error(error); |
||||
|
|
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; |
||||
|
|
||||
|
export function getRedisConnectionOptions( |
||||
|
configurationService: ConfigurationService |
||||
|
) { |
||||
|
return { |
||||
|
db: configurationService.get('REDIS_DB'), |
||||
|
host: configurationService.get('REDIS_HOST'), |
||||
|
password: configurationService.get('REDIS_PASSWORD'), |
||||
|
port: configurationService.get('REDIS_PORT') |
||||
|
}; |
||||
|
} |
||||
Loading…
Reference in new issue