Gathering detailed insights and metrics for rate-limit-mongo
Gathering detailed insights and metrics for rate-limit-mongo
Gathering detailed insights and metrics for rate-limit-mongo
Gathering detailed insights and metrics for rate-limit-mongo
express-rate-limit
Basic IP rate-limiting middleware for Express. Use to limit repeated requests to public APIs and/or endpoints such as password reset.
rate-limit-redis
A Redis store for the `express-rate-limit` middleware
axios-rate-limit
Rate limit for axios.
graphql-rate-limit
Add Rate Limiting To Your GraphQL Resolvers 💂♀
npm install rate-limit-mongo
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
32 Stars
133 Commits
10 Forks
4 Watching
3 Branches
5 Contributors
Updated on 25 Jan 2023
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-5.9%
2,455
Compared to previous day
Last week
-3.3%
13,771
Compared to previous week
Last month
-8.6%
56,999
Compared to previous month
Last year
45.2%
691,243
Compared to previous year
MongoDB store for the express-rate-limit middleware.
1$ npm install --save rate-limit-mongo
1var RateLimit = require('express-rate-limit');
2var MongoStore = require('rate-limit-mongo');
3
4var limiter = new RateLimit({
5 store: new MongoStore({
6 uri: 'mongodb://127.0.0.1:27017/test_db',
7 user: 'mongouser',
8 password: 'mongopassword',
9 // should match windowMs
10 expireTimeMs: 15 * 60 * 1000,
11 errorHandler: console.error.bind(null, 'rate-limit-mongo')
12 // see Configuration section for more options and details
13 }),
14 max: 100,
15 // should match expireTimeMs
16 windowMs: 15 * 60 * 1000
17});
18
19// apply to all requests
20app.use(limiter);
uri: string -- uri for connecting to mongodb, mongodb://127.0.0.1:27017/test_db
for example.
Required if collection hasn't been set.
collectionName: string -- name of collection for storing records. Defaults to expressRateRecords
user: string -- username for authentication in mongodb
password: string -- password for authentication in mongodb
authSource: string -- db name against which authenticate use. If not set db name from uri will be taken.
collection: object -- mongodb collection instance. Required if uri hasn't been set.
connectionOptions: object -- mongodb connection options. Allows to pass additional connection options to mongodb. The default connection options are useUnifiedTopology: true
, useNewUrlParser: true
.
expireTimeMs: integer -- time period, in milliseconds, after which record will be reset (deleted).
Defaults to 60 * 1000
. Notice that current implementation uses on mongodb ttl indexes - background task that removes expired documents runs every 60 seconds. As a result, documents may remain in a collection during the period between the expiration of the document and the running of the background task. See mongodb ttl indexes doc for more information.
Note: unless express-tate-limit's headers are disabled, windowMs
on express-tate-limit's options should be set to the same value as expireTimeMs
on rate-limit-mongo's options in order for the Retry-After
header to be correct.
resetExpireDateOnChange: boolean -- indicates whether expireDate should be reset when changed or not.
Defaults to false
.
errorHandler: function -- function that will be called if error happened
during incr, decrement or resetKey methods. Defaults to _.noop
.
createTtlIndex: boolean -- defines whether create ttl index (
on expirationDate
field with expireAfterSeconds: 0
) on collection
or not. Could be useful in situations when you don't want to create index
from the app e.g. due to restricted db permissions (see
#15 for details).
Defaults to true
.
MongoStore
class provides public methods (incr
, decrement
, resetKey
)
required by express-rate-limit.
In addition following methods provided:
getClient(callback)
- if collection
was not passed to the constructor then
that method will pass (as second argument) initiated instace of
MongoClient
to the callback
, otherwise null
will be passed. Thus this method provides
control over connection initiated by the library to the end user. This method
is promisified (when util.promisify
is presented (node.js >= 8)).No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
Reason
Found 1/9 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- 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
license file not detected
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
Reason
13 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
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