Giter Site home page Giter Site logo

express-brute-mongo's Introduction

MongoDB store adapter for the express-brute.

Installation

npm install express-brute-mongo

Usage

var ExpressBrute = require('express-brute'),
var MongoStore = require('express-brute-mongo');
var MongoClient = require('mongodb').MongoClient;

var store = new MongoStore(function (ready) {
  MongoClient.connect('mongodb://127.0.0.1:27017/test', function(err, db) {
    if (err) throw err;
    ready(db.collection('bruteforce-store'));
  });
});

var bruteforce = new ExpressBrute(store);

app.post('/auth',
  bruteforce.prevent, // error 403 if we hit this route too often
  function (req, res, next) {
    res.send('Success!');
  }
);

Expire documents

Create an index with expireAfterSeconds: 0 in mongo as follows:

db.my_api_limits_coll.ensureIndex({expires: 1}, {expireAfterSeconds: 0});

Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.

Author

Auth0

License

This project is licensed under the MIT license. See the LICENSE file for more info.

express-brute-mongo's People

Contributors

beldenge avatar dirceu avatar jfromaniello avatar ntotten avatar pose avatar samio avatar vvakame avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

express-brute-mongo's Issues

weird exception

TypeError: Cannot read property 'findOne' of undefined
  at [object Object].MongoStore.get (/root/idlebot/src/modules/idle/node_modules/express-brute-mongo/index.js:37:13)
  at [object Object].<anonymous> (/root/idlebot/src/modules/idle/node_modules/express-brute/index.js:82:15)
  at keyFunc (/root/idlebot/src/modules/idle/node_modules/express-brute/index.js:49:41)
  at [object Object].<anonymous> (/root/idlebot/src/modules/idle/node_modules/express-brute/index.js:57:3)
  at Layer.handle [as handle_request] (/root/idlebot/src/modules/idle/node_modules/express/lib/router/layer.js:82:5)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/route.js:100:13)
  at Route.dispatch (/root/idlebot/src/modules/idle/node_modules/express/lib/router/route.js:81:3)
  at Layer.handle [as handle_request] (/root/idlebot/src/modules/idle/node_modules/express/lib/router/layer.js:82:5)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:234:24
  at Function.proto.process_params (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:312:12)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:228:12
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at Function.proto.handle (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:165:3)
  at router (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:34:12)
  at Layer.handle [as handle_request] (/root/idlebot/src/modules/idle/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:270:13)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:237:9
  at Function.proto.process_params (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:312:12)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:228:12
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:559:15
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:186:14)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:191:16
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at Function.proto.handle (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:165:3)
  at router (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:34:12)
  at Layer.handle [as handle_request] (/root/idlebot/src/modules/idle/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:270:13)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:237:9
  at Function.proto.process_params (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:312:12)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:228:12
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:559:15
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:186:14)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:191:16
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:191:16
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at Function.proto.handle (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:165:3)
  at router (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:34:12)
  at Layer.handle [as handle_request] (/root/idlebot/src/modules/idle/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:270:13)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:237:9
  at Function.proto.process_params (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:312:12)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:228:12
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:559:15
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:186:14)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:191:16
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:191:16
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at Function.proto.handle (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:165:3)
  at router (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:34:12)
  at Layer.handle [as handle_request] (/root/idlebot/src/modules/idle/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:270:13)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:237:9
  at Function.proto.process_params (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:312:12)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:228:12
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:559:15
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:186:14)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:191:16
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:191:16
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at Function.proto.handle (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:165:3)
  at router (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:34:12)
  at Layer.handle [as handle_request] (/root/idlebot/src/modules/idle/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:270:13)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:237:9
  at Function.proto.process_params (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:312:12)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:228:12
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:559:15
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:186:14)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:191:16
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:191:16
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at Function.proto.handle (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:165:3)
  at router (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:34:12)
  at Layer.handle [as handle_request] (/root/idlebot/src/modules/idle/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:270:13)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:237:9
  at Function.proto.process_params (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:312:12)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:228:12
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:559:15
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:186:14)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:191:16
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:191:16
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at Function.proto.handle (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:165:3)
  at router (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:34:12)
  at Layer.handle [as handle_request] (/root/idlebot/src/modules/idle/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:270:13)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:237:9
  at Function.proto.process_params (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:312:12)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:228:12
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:559:15
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:186:14)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:191:16
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:191:16
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:191:16
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at Function.proto.handle (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:165:3)
  at router (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:34:12)
  at Layer.handle [as handle_request] (/root/idlebot/src/modules/idle/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:270:13)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:237:9
  at Function.proto.process_params (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:312:12)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:228:12
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:559:15
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:186:14)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:191:16
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:191:16
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at Function.proto.handle (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:165:3)
  at router (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:34:12)
  at Layer.handle [as handle_request] (/root/idlebot/src/modules/idle/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:270:13)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:237:9
  at Function.proto.process_params (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:312:12)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:228:12
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:559:15
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:186:14)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:191:16
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at Function.proto.handle (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:165:3)
  at router (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:34:12)
  at Layer.handle [as handle_request] (/root/idlebot/src/modules/idle/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:270:13)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:237:9
  at Function.proto.process_params (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:312:12)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:228:12
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:559:15
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:186:14)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:191:16
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:191:16
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:191:16
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:191:16
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at Function.proto.handle (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:165:3)
  at router (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:34:12)
  at Layer.handle [as handle_request] (/root/idlebot/src/modules/idle/node_modules/express/lib/router/layer.js:82:5)
  at trim_prefix (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:270:13)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:237:9
  at Function.proto.process_params (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:312:12)
  at /root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:228:12
  at Function.match_layer (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:295:3)
  at next (/root/idlebot/src/modules/idle/node_modules/express/lib/router/index.js:189:10)
  at /root/idlebot/src/modules/idle/node_modules/body-parser/lib/read.js:107:5
  at IncomingMessage.onEnd (/root/idlebot/src/modules/idle/node_modules/body-parser/node_modules/raw-body/index.js:136:7)
  at IncomingMessage.g (events.js:199:16)
  at IncomingMessage.EventEmitter.emit (events.js:104:17)
  at _stream_readable.js:898:16
  at process._tickCallback (node.js:343:11)

TypeError: db.collection is not a function

TypeError: db.collection is not a function
at MongoClient.connect (/Users/USER/Sites/PROJECT/routers/v1/api.js:23:14)
at args.push (/Users/cesarguadarrama/Sites/PROJECT/node_modules/mongodb/lib/utils.js:404:72)
at /Users/USER/Sites/PROJECT/node_modules/mongodb/lib/mongo_client.js:255:5
at connectCallback (/Users/USER/Sites/PROJECT/node_modules/mongodb/lib/mongo_client.js:933:5)
at /Users/USER/Sites/PROJECT/node_modules/mongodb/lib/mongo_client.js:794:11
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)

MongoDB version v3.4.2
Mongoose version 5.0.0-rc2
Node version v8.9.0

[UPDATE]: Seems to be a mongoose issue

How to expire?

In the Expire Documents section of README.md, should

db.my_api_limits_coll.ensureIndex({expires: 1}, {expires: 0});

be

db.my_api_limits_coll.ensureIndex({expires: 1}, {expireAfterSeconds: 0});

?
Sorry if this is a dumb question; I'm very new to MongoDB.

Cannot install package

$ npm install express-brute-mongo

npm ERR! peerinvalid The package express-brute does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants express-brute@~0.5.0

Duplicate key error in collection

I've set up the module and seems to be working fine, however I'm getting duplicate key errors:
errmsg: 'E11000 duplicate key error collection: mydb.ratelimits index: _id_ dup key: { : "G/IAnx1Agvj9X0JzMvChzHFl6jKU0ps4dnfVvJ+ZYTc=" }' } }

I've ensured the index to be set, this is my implementation:

var MongoStore = require('express-brute-mongo');
var MongoClient = require('mongodb').MongoClient;

var bruteStore = new MongoStore(function (ready) {
  MongoClient.connect(process.env['DB_URL'], function (err, db) {
    if (err) throw err;
    db.collection('ratelimits').ensureIndex({expires: 1}, {expireAfterSeconds: 0});
    ready(db.collection('ratelimits'));
  });
});

This is the middleware I set up (same as defaults, but logging the dup key error):

var rateLimitMiddleware = new ExpressBrute(bruteStore, {
  failCallback: function (req, res, next, nextValidRequestDate) {
    var err = new Error('Too many attempts.');
    err.status = 429;
    next(err);
  },
  handleStoreError: function (error) {
    console.log(error);
  }
});

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.