1.0.1 • Published 2 years ago

rt-limit v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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();
});