Skip to content

feat: Make resolveValue protected #2254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gurgunday
Copy link

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Hey! It would be useful if resolveValue was protected instead of private, that way it can be used in Guards that extend ThrottlerGuard. Especially when canActivate is modified, we still need to process ThrottlerOptions, so having access to super.resolveValue would prevent repetitive code

What is the new behavior?

resolveValue is callable from child classes

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@gurgunday gurgunday changed the title feat: make resolveValue protected feat: Make resolveValue protected Feb 7, 2025
@micalevisk
Copy link
Member

I guess resolveValue is more like an internal utility, which is why it is not public. And, to make sense of this, you may have to code the whole logic of retrieving those routeOrClass* variables as well.

Instead of changing this (an leaking internals stuff), we could have high-level methods to extract those parameters somehow, I guess?

const limit = await this.resolveValue(context, routeOrClassLimit || namedThrottler.limit);
const ttl = await this.resolveValue(context, routeOrClassTtl || namedThrottler.ttl);
const blockDuration = await this.resolveValue(
context,
routeOrClassBlockDuration || namedThrottler.blockDuration || ttl,
);
const getTracker =
routeOrClassGetTracker || namedThrottler.getTracker || this.commonOptions.getTracker;
const generateKey =
routeOrClassGetKeyGenerator || namedThrottler.generateKey || this.commonOptions.generateKey;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants