Skip to content

Latest commit

 

History

History
40 lines (32 loc) · 915 Bytes

README.md

File metadata and controls

40 lines (32 loc) · 915 Bytes

express-brute-dynamo

DynamoDB adapter for the express-brute middleware

Installation

via npm:

  $ npm install express-brute-dynamo

Usage

var app = express();
var ExpressBrute = require('express-brute');
var AWS = require('aws-sdk');
AWS.config.update({ region: 'eu-west-1' });
var db = new AWS.DynamoDB();
var DynamoStore = require('express-brute-dynamo');
var tableName = "BruteData";

store = new DynamoStore(db, tableName); // stores state in DynamoDB

setInterval(function() {
    store.clean();
}, 500000);// cleaning database BruteData

var bruteforce = new ExpressBrute(store, {
    freeRetries: 5,
    minWait: 5*60*1000, // 5 minutes
    maxWait: 30*60*1000, // 30 minutes
    lifetime: 6*60*60 // 6 hours
});

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