Skip to content

Commit

Permalink
chore: create changeset for version 5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcdo29 committed Sep 4, 2023
1 parent b22085f commit 2f4f2a7
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .changeset/shiny-adults-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
'@nestjs/throttler': major
---

Allow for multiple Throttler Contexts

# BREAKING CHANGES

- ttl is now in milliseconds, not seconds, but there are time helper exposed to
ease the migration to that
- the module options is now either an array or an object with a `throttlers`
array property
- `@Throttle()` now takes in an object instead of two parameters, to allow for
setting multiple throttle contexts at once in a more readable manner
- `@ThrottleSkip()` now takes in an object with string boolean to say which
throttler should be skipped

# HOW TO MIGRATE

For most people, wrapping your options in an array will be enough.

If you are using a custom storage, you should wrap you `ttl` and `limit` in an
array and assign it to the `throttlers` property of the options object.

Any `@ThrottleSkip()` should now take in an object with `string: boolean` props.
The strings are the names of the throttlers. If you do not have a name, pass the
string `'default'`, as this is what will be used under the hood otherwise.

Any `@Throttle()` decorators should also now take in an object with string keys,
relating to the names of the throttler contexts (again, `'default'` if no name)
and values of objects that have `limit` and `ttl` keys.

**IMPORTANT**: The `ttl` is now in **miliseconds**. If you want to keep your ttl
in seconds for readability, usethe `seconds` helper from this package. It just
multiplies the ttl by 1000 to make it in milliseconds.

0 comments on commit 2f4f2a7

Please sign in to comment.