Skip to content

Commit

Permalink
feat: add guard method for conditional skipping on override
Browse files Browse the repository at this point in the history
ref: #970
  • Loading branch information
jmcdo29 committed Sep 4, 2023
1 parent 31b14d5 commit 0ca0e94
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/throttler.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export class ThrottlerGuard implements CanActivate {
const handler = context.getHandler();
const classRef = context.getClass();

if (await this.shouldSkip(context)) {
return true;
}
const continues: boolean[] = [];
for (const namedThrottler of this.throttlers) {
// Return early if the current route should be skipped.
Expand Down Expand Up @@ -89,6 +92,10 @@ export class ThrottlerGuard implements CanActivate {
return continues.every((cont) => cont);
}

protected async shouldSkip(_context: ExecutionContext): Promise<boolean> {
return false;
}

/**
* Throttles incoming HTTP requests.
* All the outgoing requests will contain RFC-compatible RateLimit headers.
Expand Down

0 comments on commit 0ca0e94

Please sign in to comment.