Skip to content

Releases: adonisjs/limiter

Fix X-RateLimit-Reset header to use ISO date time strings

02 Aug 05:58
Compare
Choose a tag to compare
  • fix: format X-RateLimit-Reset header as an ISO string e7c4fbd
  • chore: update dependencies 3fa97e1

Full Changelog: v2.3.1...v2.3.2

Update dependencies

22 Jun 11:23
Compare
Choose a tag to compare

Full Changelog: v2.3.0...v2.3.1

Final set of improvements during the public release

07 Feb 05:57
Compare
Choose a tag to compare
  • 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

06 Feb 18:03
Compare
Choose a tag to compare
  • 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

06 Feb 11:39
Compare
Choose a tag to compare
  • 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

06 Feb 04:35
Compare
Choose a tag to compare

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

05 Feb 12:09
Compare
Choose a tag to compare
  • 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

05 Feb 11:29
Compare
Choose a tag to compare

Breaking changes

  • Remove container binding Adonis/Addons/Limiter in favor of container services and limiter.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 of HttpLimiter. The API is still the same.
  • Remove Throttle middleware, since limiterManager.define method now returns a middleware function that can be applied to routes directly.
  • Remove property LimiterResponse.retryAfter in favor of LimiterResponse.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

New Contributors

Full Changelog: v1.0.2...v2.1.0

Fix throttle middleware to block keys when blockDuration is defined

27 Apr 07:53
Compare
Choose a tag to compare
  • 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

Add peer dependencies

25 Jul 05:02
Compare
Choose a tag to compare
  • chore: add peer dependencies b0dc14a
  • chore: add repo details 57cf47f

v1.0.0...v1.0.1