npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

super-rate-limiter

v1.1.0

Published

Flexible rate limiting middleware for Express with multiple algorithms and storage options

Downloads

7

Readme

Super Rate Limiter 🚀

npm version License: MIT

A flexible, production-ready rate limiting middleware for Express.js with support for multiple algorithms and pluggable storage backends.


✨ Features

  • 🎯 Multiple Algorithms

    • ✅ Fixed Window
    • ✅ Sliding Window
    • ✅ Token Bucket
    • ✅ Leaky Bucket
  • 💾 Storage Backends

    • In-Memory (single instance)
    • Redis (distributed environments) [Coming Soon]
  • 🔑 Flexible Key Extraction

    • Based on IP, API key, user ID, etc.
  • High Performance

    • Minimal latency overhead, async-ready
  • 🛡️ Type Safe

    • Fully written in TypeScript

📦 Installation

npm install super-rate-limiter
# or
yarn add super-rate-limiter

🚦 Basic Usage

import express from 'express';
import { superRateLimiter } from 'super-rate-limiter';

const app = express();

app.use(superRateLimiter({
  algorithm: 'fixed-window',
  storeType: 'in-memory',
  maxRequests: 100,
  windowSizeInMS: 60 * 1000, // 1 minute
}));

app.get('/', (req, res) => res.send('Hello World!'));

🧠 Advanced Usage

🔑 Custom Key Extraction

app.use('/api', superRateLimiter({
  algorithm: 'leaky-bucket',
  storeType: 'in-memory',
  capacity: 10,
  leakRatePerSec: 1,
  keyExtractor: (req) => req.headers['api-key'] as string,
}));

📚 API Reference

superRateLimiter(options: RateLimiterOptions)

| Parameter | Type | Required | Description | | -------------- | ------------------------------------------------------------------------------ | -------- | ----------------------------------------------------- | | algorithm | "fixed-window" | "sliding-window" | "token-bucket" | "leaky-bucket" | ✅ | Rate limiting algorithm to apply | | storeType | "in-memory" | "redis" | ✅ | Backend for rate limit data | | keyExtractor | (req: Request) => string | ❌ | Function to extract unique key (defaults to req.ip) |

Other fields depend on the selected algorithm:

Algorithm-Specific Options

Fixed Window & Sliding Window

| Option | Type | Required | Description | | ---------------- | ------ | -------- | --------------------------------------- | | maxRequests | number | ✅ | Max requests allowed | | windowSizeInMS | number | ✅ | Size of the time window in milliseconds |

Token Bucket

| Option | Type | Required | Description | | ------------------ | ------ | -------- | ---------------------------- | | capacity | number | ✅ | Maximum tokens in the bucket | | refillRatePerSec | number | ✅ | Tokens added per second |

Leaky Bucket

| Option | Type | Required | Description | | ---------------- | ------ | -------- | -------------------------------------------- | | capacity | number | ✅ | Max queue length | | leakRatePerSec | number | ✅ | Requests leaked per second (rate of outflow) |


🤓 Algorithms Explained

1. Fixed Window

A simple counter that resets every fixed interval.

✅ Simple, memory-efficient ❌ Susceptible to burst at edges


2. Sliding Window

Smoother version of fixed window with rolling window counting.

✅ Smooth traffic control ❌ Slightly higher memory usage


3. Token Bucket

Tokens are added at a fixed rate, requests consume tokens.

✅ Handles bursts well ✅ More flexible than fixed window ❌ Requires careful tuning


4. Leaky Bucket

Queue-like structure, processes requests at a constant rate.

✅ Smooth flow, predictable rate ❌ Can delay burst traffic


⚡ Benchmarks (In-Memory, Sample)

| Algorithm | Requests/sec | Avg Latency (ms) | | -------------- | ------------ | ---------------- | | Fixed Window | 15,000 | 0.8 | | Sliding Window | 14,000 | 0.9 | | Token Bucket | 13,500 | 1.0 | | Leaky Bucket | 13,200 | 1.1 |


🛠 Contributing

We welcome contributions!

  1. Fork the repo
  2. Create a feature branch
  3. Commit using conventional commits
  4. Include tests where applicable
  5. Submit a PR

📄 License

MIT © Sudipto Das