# throttled

> Middleware to throttle http requests

Latest version **0.1.0** (published 2015-08-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install throttled
pnpm add throttled
yarn add throttled
bun add throttled
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2015-08-31 |
| First published | 2015-08-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Isaac Suttell |
| Maintainers | isuttell |
| Keywords | express.js, node.js, middleware |

## Links

- npm: https://www.npmjs.com/package/throttled
- Repository: https://github.com/isuttell/throttled
- Issues: https://github.com/isuttell/throttled/issues
- npm.io page: https://npm.io/package/throttled

## Dependencies (3)

- [async](https://npm.io/package/async.md) ^1.2.1
- [redis](https://npm.io/package/redis.md) ^0.12.1
- [moment](https://npm.io/package/moment.md) ^2.10.3

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2015-08-31

## README

# throttled

Express.js Middleware to Throttle Requests. Supports clustering using redis.

## Usage

```js
/**
 * Configure the middleware
 *
 * @type    {Function}
 */
var throttled = require('throttled')({

  /**
   * Redis Prefix
   *
   * @type    {String}
   */
  prefix: 'throttled:',

  /**
   * How many requests to limit per period
   *
   * @type    {Number}
   */
  limit: 1000,

  /**
   * How long before the count resets in seconds
   *
   * @type    {Number}
   */
  period: 60 * 15,

  /**
   * How long should someone be banned in seconds if they exceed the limit
   *
   * @type    {Number}
   */
  ban: 15 * 60,

  /**
   * Should we use the console, a custom logger, or nothing at all
   *
   * @type    {Object|Falsey}
   */
  logger: console,

  /**
   * Redis options. Read more about them at
   * https://github.com/mranney/node_redis#rediscreateclient
   *
   * @type    {Object}
   */
  redis: {}
});

/**
 * Can be applied to your entire server
 */
app.use(throttled);

/**
 * Or a specific route
 */
app.get('/rest/resource', throttled, handleGetResource);
```

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