Comments (5)
This worked for me in the end:
var apiLimiter = rateLimit({
windowMs: 5 * 60 * 1000, // 5 minutes
max: 3,
headers: false,
handler: function(req, res) {
res.status("429").end();
},
store: new MongoStore({
uri: process.env.RATE_LIMIT_MONGO_CONFIG_CONNECTION_STRING,
collectionName: "expressRateRecords"
})
});
where connection string is:
mongodb+srv://user-name:[email protected]/expressRateRecords
So basically, username
, password
and database
defined in the connection string
and only using the uri
and collectionName
config parameters.
from rate-limit-mongo.
Hello.
There a lot of questions in this issue and I don't get them all ;)
I hope my answer about collection
and collectionName
options will be helpful - it describes how to provide connected instance of the collection.
I'm closing the issue, but if you have specific questions feel free to post.
from rate-limit-mongo.
I'm not aware of that possible issue with Cloudflare and 429, 524 http statuses, sorry cannot help with that.
from rate-limit-mongo.
@okv - it ended up being a problem with my code, so I deleted the comment related to the 524 error.
For reference, I was using:
handler: function(req, res) {
res.status("429");
},
And I don't think the request was 'terminating' and cloudflare was returning a 524 error.
So I used the following code and it resolved the issue:
handler: function(req, res) {
res.status("429").end(); // <--- just added .end()
},
from rate-limit-mongo.
This worked for me in the end:
var apiLimiter = rateLimit({ windowMs: 5 * 60 * 1000, // 5 minutes max: 3, headers: false, handler: function(req, res) { res.status("429").end(); }, store: new MongoStore({ uri: process.env.RATE_LIMIT_MONGO_CONFIG_CONNECTION_STRING, collectionName: "expressRateRecords" }) });where connection string is:
mongodb+srv://user-name:[email protected]/expressRateRecordsSo basically,
username
,password
anddatabase
defined in theconnection string
and only using theuri
andcollectionName
config parameters.
@okv Consider adding a note in the documentation that "If uri includes username and password, then do not included user and password in the config object."
from rate-limit-mongo.
Related Issues (15)
- Library attempts to create indexes HOT 10
- What is the difference between 'collectionName' and 'collection' configuration parameters? HOT 1
- Clarification of expireTimeMs and resetExpireDateOnChange configuration parameters HOT 1
- Use client's real IP address instead of proxy. HOT 3
- Maintain key and total on resetKey vs deleting HOT 4
- Typescript declaration HOT 4
- It is not immediately clear from the documentation that some public methods can take an optional callback HOT 2
- Deprecation warning HOT 6
- Cannot read property 'counter' of null HOT 2
- Use new `Store` interface from `express-rate-limit` v6 HOT 4
- Error using `connectionOptions`
- Add a CHANGELOG HOT 1
- windowMs not working HOT 7
- Add method `.close()` for disconnecting HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rate-limit-mongo.