Skip to content
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

feat: version 5.0.0 #1565

Merged
merged 22 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9847cf4
feat(guard): Add support for throwing throttling exceptions
ImChrisChen Apr 6, 2023
56d1ccc
feat: allowfor multiple throttler contexts
jmcdo29 Jul 6, 2023
c512bb4
test: update unit test for guard to have proper options
jmcdo29 Jul 6, 2023
b22085f
fix: re-use the resolve value method from a previous pr
jmcdo29 Jul 6, 2023
2f4f2a7
chore: create changeset for version 5.0.0
jmcdo29 Jul 6, 2023
1fbf8a7
fix: better write out the time helper utilities
jmcdo29 Jul 6, 2023
530d58a
fix: update types of storage on interface
jmcdo29 Jul 6, 2023
0017842
feat: make method for getting error message
jmcdo29 Jul 6, 2023
31b14d5
fix: await the async throw
jmcdo29 Jul 6, 2023
0ca0e94
feat: add guard method for conditional skipping on override
jmcdo29 Jul 6, 2023
3dadcdb
chore: update changelog
jmcdo29 Jul 6, 2023
13f4b5a
fix: ttl and limit are no longer optional
jmcdo29 Jul 6, 2023
f371794
chore: add another breaking change to changelog
jmcdo29 Jul 6, 2023
a964e51
fix: remove storage property from interface
jmcdo29 Jul 6, 2023
d36acf4
chore: mention the removal of the storage property
jmcdo29 Jul 6, 2023
4396fa6
feat: get tracker can be async
jmcdo29 Jul 6, 2023
19ccc45
chore: changeset update for async tracker
jmcdo29 Jul 6, 2023
907c1a4
feat: allowfor multiple throttler contexts
jmcdo29 Jul 6, 2023
541f45c
test: update unit test for guard to have proper options
jmcdo29 Jul 6, 2023
2a597c8
fix: ttl and limit are no longer optional
jmcdo29 Jul 6, 2023
864dc0d
chore: finishing resolving merge conflicts
jmcdo29 Jul 7, 2023
29e3164
chore: update eslint to ingore underscore args
jmcdo29 Sep 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .changeset/shiny-adults-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
'@nestjs/throttler': major
---

# FEATURES

- allow for multiple Throttler Contexts
- allow for conditionally skipping based on `ThrottleGuard#shouldSkip` method
- allow for easily overriding throttler message based on guard method
- extra context passed to throw method for better customization of message
- `ThrottlerStorage` no longer needs a `storage` property`
- `getTracker` can now be async

# 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
- `ttl` and `limit` are no longer optional in the module's options. If an option
object is passed, it **must** define the defaults for that throttler

# 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.
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ module.exports = {
jest: true,
},
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{ varsIgnorePattern: '^_', argsIgnorePattern: '^_' },
],
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
Expand Down
Loading