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

express-quick-limiter

v1.0.0

Published

Fast, lightweight, zero-dependency sliding-window rate limiting middleware for Express and Node.js.

Readme

express-quick-limiter

Fast, lightweight, zero-dependency sliding-window rate limiting middleware for Express and Node.js applications.

Installation

npm install express-quick-limiter

or with yarn:

yarn add express-quick-limiter

or with pnpm:

pnpm add express-quick-limiter

Quick Start

1. Global Rate Limiter

import express from 'express';
import quickLimiter from 'express-quick-limiter';

const app = express();

// Limit each IP to 100 requests per 15 minutes
const limiter = quickLimiter({
  windowMs: 15 * 60 * 1000,
  max: 100,
  message: {
    status: 429,
    error: 'Too Many Requests',
    message: 'Too many requests from this IP, please try again later.',
  },
});

app.use(limiter);

app.get('/api/data', (req, res) => {
  res.json({ success: true });
});

app.listen(3000);

2. Route-Specific Rate Limiter (e.g. Auth / Login)

Protect brute-force endpoints with stricter limits:

const authLimiter = quickLimiter({
  windowMs: 60 * 1000, // 1 minute
  max: 5, // max 5 login attempts per minute
  message: 'Too many login attempts. Please try again after 1 minute.',
});

app.post('/api/login', authLimiter, (req, res) => {
  // Handle login logic
});

3. Rate Limit by User ID or API Key

const apiLimiter = quickLimiter({
  windowMs: 60 * 1000,
  max: 60,
  keyGenerator: (req) => {
    // Rate limit per API Key or Bearer Token
    return req.headers['x-api-key'] || req.ip;
  },
});

app.use('/api', apiLimiter);

4. Skip Whitelisted Endpoints

const limiter = quickLimiter({
  windowMs: 15 * 60 * 1000,
  max: 100,
  skip: (req) => {
    // Skip healthcheck routes or internal services
    return req.path === '/health' || req.ip === '127.0.0.1';
  },
});

5. Programmatic Key Reset

// Reset a user's rate limit upon successful verification / admin action
limiter.resetKey('192.168.1.1');

Response Headers

When rate limiting is active, express-quick-limiter automatically attaches the standard HTTP rate limit headers:

  • RateLimit-Limit: Maximum allowed requests within the window
  • RateLimit-Remaining: Number of remaining allowed requests
  • RateLimit-Reset: Time remaining until window reset (seconds)
  • Retry-After: Seconds until the client can retry (when rate-limited)
  • X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset

Configuration Options

| Option | Type | Default | Description | | :--- | :--- | :--- | :--- | | windowMs | number | 900000 (15m) | Time frame window in milliseconds | | max | number \| (req) => number | 100 | Max requests allowed within windowMs | | statusCode | number | 429 | HTTP status code returned when limit exceeded | | message | string \| object \| (req, res) => any | Standard JSON | Response sent when limit is reached | | keyGenerator | (req) => string | Client IP | Function to extract unique client key | | skip | (req, res) => boolean | undefined | Function to skip rate limiting for requests | | headers | boolean | true | Send standard rate limit headers | | skipSuccessfulRequests | boolean | false | Don't count requests with status < 400 | | skipFailedRequests | boolean | false | Don't count requests with status >= 400 | | store | Store | MemoryStore | Custom storage mechanism |

License

MIT