jcabot21 / express-simple-throttler

Simple throttling middleware, slows down requests.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Express-Simple-Throttler

npm version CircleCI Coverage Status

Super tiny helper middleware for slowing down requests. Use for your testing.

Install

npm install express-simple-throttler

How-to

The middleware comes in two flavors, constant and random.

Constant

const throttler = require('express-throttler');
const app = require('express')();
const twentySeconds = 20 * 1000;

app.use(throttler(twentySeconds));

// Setup your routes, now they are all super slow
// ...

Random

const throttler = require('express-throttler');
const app = require('express')();
const upToTwentySeconds = 20 * 1000;

app.use(throttler(upToTwentySeconds, true));

// Setup your routes, now some may be super slow
// ...

Tests

Tests are run with jasmine through the test command as follows:

npm test

About

Simple throttling middleware, slows down requests.

License:MIT License


Languages

Language:JavaScript 100.0%