Added
express
4.x as a peer dependency.- Better Typescript support (the library was rewritten in Typescript).
- Export the package as both ESM and CJS.
- Publish the built package (
.tgz
file) on GitHub releases as well as the npm registry. - Issue and PR templates.
- A contributing guide.
- A changelog.
Changed
- Rename the
draft_polli_ratelimit_headers
option tostandardHeaders
. - Rename the
headers
option tolegacyHeaders
. Retry-After
header is now sent if eitherlegacyHeaders
orstandardHeaders
is set.- Allow
keyGenerator
to be an async function/return a promise. - Change the way custom stores are defined.
- Add the
init
method for stores to set themselves up using options passed to the middleware. - Rename the
incr
method toincrement
. - Allow the
increment
,decrement
,resetKey
andresetAll
methods to return a promise. - Old stores will automatically be promisified and used.
- Add the
- The package can now only be used with NodeJS version 12.9.0 or greater.
- The
onLimitReached
configuration option is now deprecated. Replace it with a customhandler
that checks the number of hits.
Removed
- Remove the deprecated
limiter.resetIp
method (use thelimiter.resetKey
method instead). - Remove the deprecated options
delayMs
,delayAfter
(the delay functionality was moved to theexpress-slow-down
package) andglobal
(use a key generator that returns a constant value).