Skip to content

Commit

Permalink
add README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
MunifTanjim committed May 5, 2018
1 parent 53472f1 commit 167c58b
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 2 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,3 @@ typings/

# dotenv environment variables file
.env

81 changes: 80 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,81 @@
[![GitHub release](https://img.shields.io/github/release/MunifTanjim/express-brute-lowdb.svg?style=for-the-badge)](https://github.com/MunifTanjim/express-brute-lowdb/releases/latest)
[![GitHub Release Date](https://img.shields.io/github/release-date/MunifTanjim/express-brute-lowdb.svg?style=for-the-badge)](https://github.com/MunifTanjim/express-brute-lowdb/releases)
[![license](https://img.shields.io/github/license/MunifTanjim/express-brute-lowdb.svg?style=for-the-badge)](https://github.com/MunifTanjim/express-brute-lowdb/blob/master/LICENSE)

# express-brute-lowdb
A lowdb storage adapter for express-brute middleware

A [lowdb](https://github.com/typicode/lowdb) storage adapter for [express-brute](https://github.com/AdamPflug/express-brute) middleware

## Installation

via **npm**:

```shell
$ npm install express-brute-lowdb
```

via **yarn**:

```shell
$ yarn add express-brute-lowdb
```

## Usage

```js
const ExpressBrute = require('express-brute')
const LowdbStore = require('express-brute-lowdb');

const store = new LowdbStore();
const bruteforce = new ExpressBrute(store);

app.post('/auth',
bruteforce.prevent,
(req, res, next) => {
res.send('Success!')
}
);
```

## Options

Available options:

| Name | Type | Description | Required
| ------------- | ---------- |-------------------------------------- | ----------
| `prefix` | `String` | Prefix for each lowdb key | _false_
| `adapter` | `Function` | lowdb adapter Constructor | _false_
| `adapterArgs` | `Array` | Arguments for adapter Constructor | _false_
| `rootKey` | `String` | name for database objects's root key | _false_

Example:

```js
const Memory = require('lowdb/adapters/Memory') // or
const FileSync = require('lowdb/adapters/FileSync')

// defaults:
const options = {
prefix: '',
adapter: Memory, // only `Memory` & `FileSync` adapters are currently supported
adapterArgs: ['express-brute.json'],
rootKey: 'express-brute'
}

const store = new LowdbStore(options);
```

**N.B.**: lowdb's `Memory` adapter is not suitable for production usage

### Useful Links

- [lowdb Adapters API](https://github.com/typicode/lowdb#adapters-api)

## Changelog

[Changelog for express-brute-lowdb](https://github.com/MunifTanjim/express-brute-lowdb/blob/master/CHANGELOG.md)

## License

Licensed under the MIT License. Check the [LICENSE](https://github.com/MunifTanjim/express-brute-lowdb/blob/master/LICENSE) file for details.

0 comments on commit 167c58b

Please sign in to comment.