flood-protection
Flood protection for realtime applications
![npm](https://img.shields.io/npm/dt/flood-protection.svg)
Install
npm install --save flood-protection
Usage
import FloodProtection from 'flood-protection';
const floodProtection = new FloodProtection({
rate: 5,
per: 8,
});
Basic Example
import FloodProtection from 'flood-protection';
io.on('connection', (client) => {
client.emit('connected');
const floodProtection = new FloodProtection();
client.on('message', (text) => {
if (floodProtection.check()) {
io.emit('message', text);
} else {
client.emit('flood', {
text: 'Take it easy!',
});
}
});
});
LICENCE
MIT (c) 2017 Mehmet Yatkı