1.1.2 • Published 8 years ago

hapi-ratelimit-mongoose v1.1.2

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

hapi-ratelimit-mongoose npm version

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

//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

//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.
1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago