nestjs / throttler

A rate limiting module for NestJS to work with Fastify, Express, GQL, Websockets, and RPC 🧭

Home Page:https://nestjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for async `getTracker`

amrsalama opened this issue · comments

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

Current implementation of ThrottlerGuard supports only sync getTracker

Describe the solution you'd like

Convert

protected getTracker(req: Record<string, any>): string;

To

protected getTracker(req: Record<string, any>): string | Promise<string>;

Teachability, documentation, adoption, migration strategy

No response

What is the motivation / use case for changing the behavior?

In some cases we might need to do async operations to generate a proper tracker for the request, e.g. to verify and decode authorization token.