npm install express-brute-loki
var ExpressBrute = require('express-brute'),
ExpressBruteLokiStore = require('express-brute-loki');
var store = new ExpressBruteLokiStore({
path: './brute.db' // See all available options below
});
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!');
}
);
Setting the path
to the database file is optional but recommended.
Available parameters:
path
Path to the database file. Defaults to./brute-store.db
autosave
Setfalse
to disable save to disk. Defaults totrue
ttl
Duration in seconds to keep entries. Set to0
to disable TTL. Defaults to0
logErrors
Whether or not to log client errors. Defaults tofalse
- If
true
, a default logging function (console.error
) is provided. - If a function, it is called anytime an error occurs (useful for custom logging)
- If
false
, no logging occurs.
- If
MIT