Skip to content

Releases: austinksmith/Ration.js

Version v2.1.0 Released!

16 Mar 01:24

Choose a tag to compare

I'm happy to announce the release of v2.1.0 of Ration.js this new release includes several performance improvements and bug fixes as well as a new option to forcibly drop connections of offending users instead of slowing their requests down.

Simply set dropConnections to true in your rationjs options and any user exceeding their rations will have their requests dropped instead of being queued up with a delay.

/* Set Ration.js Options */
const rations = {
  maxRequestsPerTimeFrame: 600,
  timeFrameInSeconds: 30,
  removeRecordsAfter: (1000 * 60 * 5),
  dropConnections: true
};
rationjs.setRations(rations);

/* Use Ration.js */
app.use(rationjs.startRations);

v2.0.0 Released!

27 Feb 22:02

Choose a tag to compare

This release converts the library into a reusable ES6 class and reduces the overall library complexity significantly. Additionally you can now configure the different ration settings (rations) you want to enforce.

Ration.js Options

  • maxRequestsPerTimeFrame - This is the maximum number of requests you want to allow an application user to use within the set timeframe. Value should be an Integer - Defaults to 600.
  • timeFrameInSeconds - This is the time frame you want to limit the number of requests within eg. Use 1 to limit requests by individual seconds - Defaults to 30
  • removeRecordsAfter - This is the amount of time since the requestors last request that the requestors records are kept in memory - milliseconds - Defaults to 30000 (ie. 5 minutes).

New Install Instructions

  • Add Ration.js to your project using the instructions below

Node

  • Use npm install to add the project to your dependencies npm install --save ration.js
  • Require the npm module in your app.js file
    const ration = require('ration.js');

Then make sure your app is set to use ration with the following

// Declare Application
let app = express();

/* Set Ration.js Options */
const rations = {
  maxRequestsPerTimeFrame: 600,
  timeFrameInSeconds: 30,
  removeRecordsAfter: (1000 * 60 * 5)
};

/* Initialize Ration.js */
rationjs.setRations(rations);

/* Use Ration.js */
app.use(rationjs.startRations);

Enjoy!

Ration

Ration.js v1.0.1!

14 Feb 18:50

Choose a tag to compare

Ration.js

Author: Austin K. Smith

Website: Github

Description: 100% Vanilla Javascript Rate Limiting / DDOS Protection Library

License: Artistic License 2.0

About

Ration.js is 100% Vanilla Javascript Rate Limiting / DDOS Protection Library for use with Node.js / Express, inspired by Network Tarpits it works the same way to intentionally slow down requests from users who are making too many requests within a given time threshold.

Install

  • Add Ration.js to your project using the instructions below

Node

  • Use npm install to add the project to your dependencies npm install --save ration.js
  • Require the npm module in your app.js file
    const ration = require('ration.js');

Then make sure your app is set to use ration with the following

  app.use(rationjs);

How it works

  • The library acts as a middleware layer for incoming requests to your Node.js/Express application
  • WIth each unique visitor a request record is created and saved internally to keep track of time interval between each new request and the previous request
  • If the number of requests exceeds the set limit of requests within the set time threadshold, requests by the offending users are then delayed using a delayMultiplier
  • The delay multiplier is doubled for each request exceeding the number of requests allowed within the set time threshold
  • If the time difference between the last request and the current request exceeds the time threshold, the request count for the user is reset to 1
  • If there are no new requests from a unique visitor within 5 minutes, their request records are removed automatically to prevent the visits log from growing too large

Ration.js First Release!

14 Feb 18:40

Choose a tag to compare

Ration.js

Author: Austin K. Smith

Website: Github

Description: 100% Vanilla Javascript Rate Limiting / DDOS Protection Library

License: Artistic License 2.0

About

Ration.js is 100% Vanilla Javascript Rate Limiting / DDOS Protection Library for use with Node.js / Express, inspired by Network Tarpits it works the same way to intentionally slow down requests from users who are making too many requests within a given time threshold.

Install

  • Add Ration.js to your project using the instructions below

Node

  • Use npm install to add the project to your dependencies npm install --save ration.js
  • Require the npm module in your app.js file
    const ration = require('ration.js');

Then make sure your app is set to use ration with the following

  app.use(rationjs);

How it works

  • The library acts as a middleware layer for incoming requests to your Node.js/Express application
  • WIth each unique visitor a request record is created and saved internally to keep track of time interval between each new request and the previous request
  • If the number of requests exceeds the set limit of requests within the set time threadshold, requests by the offending users are then delayed using a delayMultiplier
  • The delay multiplier is doubled for each request exceeding the number of requests allowed within the set time threshold
  • If the time difference between the last request and the current request exceeds the time threshold, the request count for the user is reset to 1
  • If there are no new requests from a unique visitor within 5 minutes, their request records are removed automatically to prevent the visits log from growing too large