# @types/ratelimiter

> TypeScript definitions for ratelimiter

Latest version **3.4.6** (published 2023-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/ratelimiter
pnpm add @types/ratelimiter
yarn add @types/ratelimiter
bun add @types/ratelimiter
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.4.6 |
| Published | 2023-11-07 |
| First published | 2016-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51370 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/ratelimiter
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ratelimiter
- npm.io page: https://npm.io/package/@types/ratelimiter

## Recent versions

- 3.4.6 (latest) — 2023-11-07
- 3.4.4 (ts4.1) — 2022-10-26
- 3.4.3 (ts3.8) — 2021-12-09
- 3.4.2 (ts3.6) — 2021-07-08
- 3.4.1 (ts3.3) — 2020-12-09
- 3.4.0 (ts3.2) — 2020-11-09
- 2.1.28 (ts2.0) — 2016-09-19
- 3.4.5 — 2023-10-18
- 2.1.27 — 2016-07-14
- 2.1.26-alpha — 2016-07-08
- 2.1.25-alpha — 2016-07-04
- 2.1.24-alpha — 2016-07-02
- 2.1.23-alpha — 2016-07-01
- 2.1.22-alpha — 2016-07-01
- 2.1.21-alpha — 2016-05-25
- … 3 more at https://npm.io/package/@types/ratelimiter/versions

## README

# Installation
> `npm install --save @types/ratelimiter`

# Summary
This package contains type definitions for ratelimiter (https://github.com/tj/node-ratelimiter).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ratelimiter.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ratelimiter/index.d.ts)
````ts
interface RedisClient {
    multi(operations: any[][]): { exec(cb: (err: any, res: any) => unknown): void };
}

declare class Limiter {
    constructor(opts: Limiter.LimiterOption);

    /**
     * Inspect implementation
     */
    inspect(): string;

    /**
     * Get values and header / status code and invoke `fn(err, info)`.
     */
    get(fn: (err: any, info: Limiter.LimiterInfo) => void): void;
}

declare namespace Limiter {
    interface LimiterOption {
        /**
         * The identifier to limit against (typically a user id)
         */
        id: string;

        /**
         * Redis connection instance
         */
        db: RedisClient;

        /**
         * Max requests within duration
         * @default 2500
         */
        max?: number | undefined;

        /**
         * Duration of limit in milliseconds
         * @default 3600000
         */
        duration?: number | undefined;
    }

    /**
     * Result Object
     */
    interface LimiterInfo {
        /**
         * `max` value
         */
        total: number;

        /**
         * number of calls left in current `duration` without decreasing current `get`
         */
        remaining: number;

        /**
         * time since epoch in seconds at which the rate limiting period will end (or already ended)
         */
        reset: number;

        /**
         * time since epoch in milliseconds at which the rate limiting period will end (or already ended)
         */
        resetMs: number;
    }
}

export = Limiter;

````

### Additional Details
 * Last updated: Tue, 07 Nov 2023 09:09:39 GMT
 * Dependencies: none

# Credits
These definitions were written by [Aya Morisawa](https://github.com/AyaMorisawa), and [Piotr Błażejewicz](https://github.com/peterblazejewicz).

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