# ratelimiter-middleware

> Abstract RateLimiter which uses Redis

Latest version **2.0.4** (published 2020-09-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install ratelimiter-middleware
pnpm add ratelimiter-middleware
yarn add ratelimiter-middleware
bun add ratelimiter-middleware
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.4 |
| Published | 2020-09-09 |
| First published | 2020-09-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Kartik Rawat |
| Maintainers | kartikkhk |
| Keywords | RateLimiting, Redis, appId, rate, rate-limit, middleware, ip, auth, authorization, security, brute, brute-force, attack |

## Links

- npm: https://www.npmjs.com/package/ratelimiter-middleware
- Repository: https://github.com/kartik1998/ratelimiter-middleware
- Homepage: https://github.com/kartik1998/ratelimiter-middleware#readme
- Issues: https://github.com/kartik1998/ratelimiter-middleware/issues
- npm.io page: https://npm.io/package/ratelimiter-middleware

## Dependencies (1)

- [redis](https://npm.io/package/redis.md) ^3.0.2

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 2.0.4 (latest) — 2020-09-09
- 2.0.3 — 2020-09-09
- 2.0.2 — 2020-09-09
- 2.0.1 — 2020-09-09
- 2.0.0 — 2020-09-09
- 1.0.1 — 2020-09-09
- 1.0.0 — 2020-09-09

## README

## ratelimiter-middleware

![](https://img.shields.io/badge/npm-v1.0.0-brightgreen)
![](https://img.shields.io/badge/middleware-rate%20limit-blue)

Basic rate-limiting middleware for Express. Used to limit repeated requests to public APIs and/or endpoints. It can be used to rateLimit a specific `appId` (specified in the request headers) and by default it rateLimits IP addresses.

**Ensure that your redis server is running before using**

## Installation

`npm i --save ratelimiter-middleware`

## Usage

```
const express = require('express');
const app = express();
const rateLimiter = require('ratelimiter-middleware');

const maxRequests = 100;
const timeLimit = 60; // seconds
const appId = 'appId'; // The request header that you specify

app.use(rateLimiter(maxRequests,timeLimit, appId));

// The appId parameter can be left empty if you want to rateLimit based
// on IP address
// eg. app.use(rateLimiter(maxRequests,timeLimit));

app.get('/', (req, res) => {
  res.json({ msg: 'AoK' });
});

```

---
_Source: https://npm.io/package/ratelimiter-middleware · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
