Gathering detailed insights and metrics for express-rate-limiter
Gathering detailed insights and metrics for express-rate-limiter
Gathering detailed insights and metrics for express-rate-limiter
Gathering detailed insights and metrics for express-rate-limiter
rate-limiter-flexible
Node.js rate limiter by key and protection from DDoS and Brute-Force attacks in process Memory, Redis, MongoDb, Memcached, MySQL, PostgreSQL, Cluster or PM
express-limiter
rate limitter middleware for express applications
gl-express-rate-limiter
Rate limiting middleware
express-rate-limiter-redis
Express Rate Limiter, using Redis as the key value store.
npm install express-rate-limiter
Typescript
Module System
Node Version
NPM Version
72
Supply Chain
99.3
Quality
75.8
Maintenance
100
Vulnerability
99.6
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
5 Stars
58 Commits
3 Forks
2 Watchers
1 Branches
1 Contributors
Updated on Dec 04, 2019
Latest Version
1.3.1
Package Id
express-rate-limiter@1.3.1
Size
4.64 kB
NPM Version
2.11.3
Node Version
0.12.7
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Rate limiter middleware for express applications.
This limiter has two kinds of limits: an inner and outer limit. It limites based on user ip.
The inner limit is against hammering (e.g. only 3 calls allowed per second). The outer limit is for protecting against over-use. (e.g. max 60 times per two minutes).
The limits are currently held in memory. It's on my roadmap to abstract the use of this module, so other modules can be plugged in instead (e.g. redis).
Install
npm install express-rate-limiter --save
First, create a new Limiter;
1var Limiter = require('express-rate-limiter'); 2var MemoryStore = require('express-rate-limiter/lib/memoryStore'); 3var limiter = new Limiter({ db : new MemoryStore() });
The memory store is a lightweight in memory cache. This can be replaced by any other database implementing store.js, for example the MemoryStore.
Afterwards, use the limiter to create an express middleware for the express methods you want to rate limit.
1app.post('/', limiter.middleware(), function(req, res) { 2 3});
Anything written in the callback will now be rate limited.
#Default values
Default settings for the created middleware are as follows:
2 * 60 * 1000
2 minutes
60
60 attempts
1500
1.5 seconds
3
3 attemps
true
add headers
true
true
true
.undefined
boolean
''
They can be overwritten globally by passing them to the initiator. Properties that were not passed will automatically take default value.
1var limiter = new Limiter({innerLimit: 5});
Settings can also be overwritten per middleware. When a setting is not passed through the initiator, it will revert to the setting specified in the ctor of the Limiter you're using. If you didn't pass that setting there either, it will use the default value instead.
1app.post('/', limiter.middleware({innerLimit: 10, headers: false}), function(req, res) { 2 3});
When the limit has been reached, the actual method logic will not be executed, but instead a status 429 (Too many Requests) will be sent to the client.
#Headers Headers are automatically added to the response.
The available headers are:
For X-RateLimit
-headers, the outer limits are used as response values.
#Notes
The framework relies on the fact that express' req.ip
is correct. This might not always be the case, e.g. when running behind a proxy like NGINX or hosting your app on a platform like Heroku
.
When this is the case, don't forget to initialize express using the following snippet:
1app.enable('trust proxy');
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 2/29 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More