# hapi-ratelimit-mongoose

> This package is a Hapi.js plugin based on MongoDB & Mongoose that give a global rate limit control on your app/API. You can also set up some specific rate limits on each route config.

Latest version **1.1.2** (published 2015-12-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install hapi-ratelimit-mongoose
pnpm add hapi-ratelimit-mongoose
yarn add hapi-ratelimit-mongoose
bun add hapi-ratelimit-mongoose
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2015-12-12 |
| First published | 2015-06-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+8 in 2 direct dependencies) |
| Install scripts | no |
| Author | laudeon |
| Maintainers | laudeon |
| Keywords | hapi, hapijs, mongoose, rate limit |

## Links

- npm: https://www.npmjs.com/package/hapi-ratelimit-mongoose
- Repository: https://github.com/laudeon/hapi-ratelimit-mongoose
- Homepage: https://github.com/laudeon/hapi-ratelimit-mongoose#readme
- Issues: https://github.com/laudeon/hapi-ratelimit-mongoose/issues
- npm.io page: https://npm.io/package/hapi-ratelimit-mongoose

## Dependencies (2)

- [hapi](https://npm.io/package/hapi.md) ^11.1.2
- [mongoose](https://npm.io/package/mongoose.md) ^4.3.1

## Recent versions

- 1.1.2 (latest) — 2015-12-12
- 1.1.1 — 2015-12-12
- 1.1.0 — 2015-12-12
- 1.0.4 — 2015-08-15
- 1.0.3 — 2015-08-15
- 1.0.2 — 2015-08-08
- 1.0.1 — 2015-08-08
- 1.0.0 — 2015-08-08
- 0.1.3 — 2015-08-08
- 0.1.2 — 2015-08-08
- 0.1.1 — 2015-08-08
- 0.1.0 — 2015-06-17

## README

# hapi-ratelimit-mongoose [![npm version](https://badge.fury.io/js/hapi-ratelimit-mongoose.png)](http://badge.fury.io/js/hapi-ratelimit-mongoose)

This package is a Hapi.js plugin based on MongoDB that give a global rate limit control on your app/API. 
You can also set up some specific rate limits on each route config.

## Getting started

Go in your project root directory and install with npm:
```
npm install hapi-ratelimit-mongoose --save
```

#### Global rate limit setup

```js
//server.js or app.js ... (anywhere you setup your server)

server.register({
	register: require('hapi-ratelimit-mongoose'),
	options: {
		global: {
			limit: 20,
			duration: 5000
		}
	}
}, function(err) {
		console.log(err||'Ratelimit plugin is loaded');
});
```

#### Route rate limit setup

```js
//route.js or main.js ... (anywhere you define a route)

server.route({
    method: 'GET',
    path: '/',
    config: { 
	    plugins: { 
			'hapi-ratelimit-mongoose': {
				limit: 200,
				duration: 5000
			}
	   }
	}
});
```

##Todo

* Setup unit test (so refactor & review some part of the code)
* Add way to store IP/timestamp, not just mongoDB (JSON for example...). Then, allow to choose the storage system in the options parameter.

---
_Source: https://npm.io/package/hapi-ratelimit-mongoose · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
