@nestjs/throttler
Advanced tools
Changelog
4.2.1
b72c9cb: Revert resolvable properties for ttl and limit
The resolvable properties made a breaking change for custom guards that was unforseen. This reverts it and schedules the changes for 5.0.0 instead
Changelog
4.2.0
Changelog
4.0.0
4803dda: Rewrite the storage service to better handle large numbers of operations
The initial behavior was that getRecord()
returned an list of sorted TTL
timestamps, then if it didn't reach the limit, it will call addRecord()
.
This change was made based on the use of the Redis storage community package
where it was found how to prevent this issue. It was found out that
express-rate-limit
is incrementing a single number and returning the information in a single
roundtrip, which is significantly faster than how NestJS throttler works by
called getRecord()
, then addRecord
.
getRecord
addRecord(key: string, ttl: number): Promise<number[]>;
changes to increment(key: string, ttl: number): Promise<ThrottlerStorageRecord>;
If you are just using the throttler library, you're already covered. No changes necessary to your code, version 4.0.0 will work as is.
If you are providing a custom storage, you will need to remove your current
service's getRecord
method and rename addRecord
to incremenet
while
adhering to the new interface and returning an ThrottlerStorageRecord
object
Changelog
3.1.0
da3c950: Add skipIf
option to throttler module options
With the new option, you can pass a factory to skipIf
and determine if the throttler guard should be used in the first palce or not. This acts just like applying @SkipThrottle()
to every route, but can be customized to work off of the process.env
or ExecutionContext
object to provide better support for dev and QA environments.
Changelog
3.0.0
Changelog
2.0.1