Releases: adonisjs/limiter
Releases · adonisjs/limiter
Fix X-RateLimit-Reset header to use ISO date time strings
Full Changelog: v2.3.1...v2.3.2
Update dependencies
Full Changelog: v2.3.0...v2.3.1
Final set of improvements during the public release
- refactor: make deleteInMemoryBlockedKeys method optional b7df37b
- refactor: block keys via penalize method 49489e5
- refactor: allow duration to be optional during set method 115ed7b
- refactor: return error from penalize method instead of throwing it 8418a83
- refactor: make attempt method return early if all requests have been exhausted 225a675
Full Changelog: v2.2.1...v2.3.0
Improvements to decrement and penalize methods
- refactor: clear key when penalize method gets successful response 2133576
- refactor: make decrement method safe from getting into negative values 1479c80
Full Changelog: v2.2.0...v2.2.1
Improvements and new APIs
- feat: allow defining memory block options via limiterManager.use method 3d80aa3
- refactor: prefix throttle middleware ip key with ip_ 6b6398c
- refactor: allow connectionName in redis config to be optional 155eed4
- feat: add decrement method use atomic upserts for increment method ee886a3
Full Changelog: v2.1.2...v2.2.0
Bug fixes and improvements to initial configure process
This release will create the migration file for the rate_limits
table when database
storage provider is used. Also, the start/limiter.ts
file is created with a default throttle to throttle HTTP requests.
Commits
- fix: code to infer database name from connection config ed5296d
- feat: create start/limiter.ts file d2bea69
- refactor: make dbName flag optional if connection has pre-selected db cf4a356
- feat: create rate_limits table migration when using db store 3fb6c26
- fix: penalize method to throw limiter error when all requests have been consumed fcb1a61
- fix: redis store to infer connection name from RedisConnections interface a760ff5
Full Changelog: v2.1.1...v2.1.2
Fixes the last release
- test: fix breaking tests 89103ae
- fix: use latest tag instead of develop b08e8b7
- feat: limiter.penalize method to penalize on action failure 60e42ae
- fix: remove in memory blocked keys when clearing storage d609baf
Full Changelog: v2.1.0...v2.1.1
Final release with v6 compatibility
Breaking changes
- Remove container binding
Adonis/Addons/Limiter
in favor of container services andlimiter.manager
binding. - The import path for the limiter service has been change.
- import { Limiter } from '@adonisjs/limiter/build/services' + import limiter from '@adonisjs/limiter/services/main'
- Remove
HttpLimiterConfigBuilder
in favor ofHttpLimiter
. The API is still the same. - Remove
Throttle
middleware, sincelimiterManager.define
method now returns a middleware function that can be applied to routes directly. - Remove property
LimiterResponse.retryAfter
in favor ofLimiterResponse.availableIn
.
Breaking change in HTTP limiters
The HTTP limiters defined using the Limiter.define
method have been refactored and now the limiter.define
method returns a middleware function that can be applied to a route. Following is a brief diff for the same.
Earlier
import { Limiter } from '@adonisjs/limiter/build/services'
export const { limiters } = Limiter
.define('global', (ctx) => {
return Limiter.allowRequests(1000).every('1 min')
})
// INSIDE ROUTES FILE
Route.get('/api/reports/:id', () => {
}).middleware('throttle:global')
Now
import limiter from '@adonisjs/limiter/services/main'
export const throttle = limiter.define('global', (ctx) => {
return limiter.allowRequests(1000).every('1 min')
})
// INSIDE ROUTES FILE
import { throttle } from '#start/limiter'
router.get('/api/reports/:id', () => {
}).use(throttle)
Features
- Add
clear
method to stores and limiter manager to clear all the rate limiting data from the store. This could be helpful during testing. See docs for usage information. - Add
limiter.attempt
method run a callback if rate limiter requests have not been exhausted. - Add
limiter.penalize
method to exhaust requests when the provided callback throws an exception. - Add
availableIn
method to get the number of seconds to wait before the key becomes available.
Improvements
- The config file has been improved a lot with usage of functions and there is no need for
contracts/limiter.ts
file.
Commits
- fix: regression in throttle middleware cac6e40
- chore: publish under latest tag 0733c4c
- Merge pull request #9 from adonisjs/next 4b16c22
- tests: improve coverage b47affa
- refactor: http limiter api 098d74c
- docs: update readme 3d5cbe4
- ci: rename test.yml to checks.yml 4968eb5
- feat: add support for clearing stores 7d0a3cb
- feat: add configure hook 1fe6273
- chore: update bundling process c6bb70d
- feat: add provider and limiter service f1a41d5
- refactor: cleanup middleware logic 707803e
- feat: add support for clearing rate limits 5979a71
- feat: add define config helper 613ae20
- test: fix linter issues d7650b0
- feat: add helper to disable limits for the given request e9fa96d
- ci: fix db name ae2981b
- style: format source code 8e70667
- ci: update workflow file 92e529c
- feat: implement http limiter and throttle middleware 235b68d
- feat: add limiter manager e179cf3
- feat: implement limiter 48f1c8c
- refactor: remove existing code temporarily and get stores in working condition 46b095e
- Merge pull request #8 from fareeda0/next 90dbdac
- fix: temp workaround for tsconfig extend aa83377
- test: add configure tests abeb2e5
- feat: infer types 629293b
- refactor: reorder limiter store args 7e2583b
- fix: pass redis connection name 8bcd27f
- chore: remove types from tsconfig bb0d23a
- chore: cleanup imports 071da55
- docs: typo in docs 455ebc1
- chore: update config keys 858b654
- ci: update action versions 36d3f4a
- fix: take db name from env 7c75761
- fix: indentation in workflow f966759
- ci: update workflows 746fe8d
- test: add more tests, improve coverage 178371c
- feat: skip when disabled in config c71be80
- chore: clean up types 767bcd9
- feat: finalise stubs, remove templates bc20f37
- refactor: update meta files d17ba70
- tests: cleanup tests, add in memory tests d1f5f49
- feat: split stores, add in-memory store af716af
- fix: build script bc7e2a5
- refactor: clean up files 2c76fa4
- fix(tests): remove duplicate test 03f20b4
- test: throttle middleware tests 2505430
- refactor: update throttle middleware 4013daa
- refactor: move types file 3d5425d
- feat: add intial stubs 362ef72
- test: update tests with new config 7ab3b55
- feat: add enabled property to config 429ec4d
- refactor: bulk of v6 changes cf9bc61
What's Changed
- refactor: migrate limiter to v6 by @fareeda0 in #8
- Merge to develop for final release by @thetutlage in #9
New Contributors
- @fareeda0 made their first contribution in #8
- @thetutlage made their first contribution in #9
Full Changelog: v1.0.2...v2.1.0
Fix throttle middleware to block keys when blockDuration is defined
- chore: update dependencies 0cdd819
- test: fix tests to assert the key is blocked a3c805f
- fix: throttle middleware to block keys d22d802
Full Changelog: v1.0.1...v1.0.2