2.0.0 • Published 8 years ago
express-brute-pg v2.0.0
express-brute-pg
A PostgreSQL store for express-brute via node-postgres.
Installation
via npm:
$ npm install express-brute-pgexpress-brute-pg expects a table named brute (this may be overridden in the constructor) to exist in whatever database you're connecting to.
create table brute(id text primary key, count int, first_request timestamptz, last_request timestamptz, expires timestamptz);Usage
var ExpressBrute = require('express-brute'),
PgStore = require('express-brute-pg');
var store = new PgStore({
host: '127.0.0.1',
database: 'sandbox',
username: 'appuser',
password: 'password'
});
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!');
}
);Options
hostPostgres server host name or IP addressdatabaseDatabase name to connect tousernameDatabase usernamepasswordCorresponding password, if password authentication is requiredtableNameInclude to use a storage table named something other thanbruteschemaNameInclude if your storage table is in a schema other thanpublicpoolYou may pass in your application'spoolinstance toexpress-brute-pgto share connection pools or use the native bindings; if not supplied,express-brute-pgwill spin up its own pool