rt-limit
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

RT Limit

A simple IP address based rate limiting module written in Typescript with zero dependencies.

See how it's implemented at my blog post.

Installation

npm i rt-limit

Usage

import Ratelimit from 'rt-limit';
import express from 'express';

const ratelimit = new Ratelimit(60, 60 * 1000);
const app = express();

app.use((req, res, next) => {
  if (ratelimit.consume(req.ip, 1)) {
    next();
    return;
  }

  res.status(429).end();
});

Readme

Keywords

Package Sidebar

Install

npm i rt-limit

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

6.53 kB

Total Files

9

Last publish

Collaborators

  • cyruskao