1.0.0 • Published 4 years ago

historycounter v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

HistoryCounter

Simple Node.JS flood control

Install

npm i github:flyink13/historycounter

Usage

const HistoryCounter = require("historycounter");
const floodIp = new HistoryCounter();
const max_requests_peer_minute = 60;

(function onRequest() {
  const user_id = 61351294; // req.ip, payload.user_id etc.
  if (floodIp.checkCount(user_id, max_requests_peer_minute)) {
    throw { error: 'flood control' };
  }
})();
1.0.0

4 years ago