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

@the-node-forge/api-rate-limit

v1.0.8

Published

A simple and efficient API rate limiter for JavaScript/TypeScript applications

Readme

API Rate Limiter

License: MIT

Made with TypeScript

NPM Version Build Status Platform

Live Documentation

A simple and efficient API rate limiter for JavaScript/TypeScript applications. This package helps developers limit API requests per user, preventing abuse and excessive usage.

✨ Features

  • Configurable Limits – Set max requests per second, minute, or hour.
  • In-Memory Storage – Fast and lightweight.
  • Express Middleware – Easily integrate with Express.
  • Multiple Users – Tracks each user separately.

📦 Installation

npm install @the-node-forge/api-rate-limit

or using Yarn:

yarn add @the-node-forge/api-rate-limit

🛠️ Basic Usage

1️⃣ 🌐 JavaScript/TypeScript Example

Easily integrate with JavaScript/TypeScript.

// Javascript
import RateLimiter from '@the-node-forge/api-rate-limit';

// Create a rate limiter allowing 5 requests per minute
const limiter = new RateLimiter({ windowMs: 60000, maxRequests: 5 });

const userId = 'user123'; // Could be an API key or IP

if (limiter.isAllowed(userId)) {
  console.log('Request allowed ✅');
} else {
  console.log('Too many requests ❌');
}

2️⃣ 🌐 Express Middleware Example - Global

Easily integrate with an Express API.

import express from 'express';
// ESM
import { RateLimiter, rateLimitMiddleware } from '@the-node-forge/api-rate-limit';
// or CommonJs
const {
  RateLimiter,
  rateLimitMiddleware,
} = require('@the-node-forge/api-rate-limit');

const app = express();

// Set up rate limiter (10 requests per minute)
const limiter = new RateLimiter({ windowMs: 60000, maxRequests: 10 });

// Apply middleware globally
app.use(rateLimitMiddleware(limiter));

app.get('/', (req, res) => {
  res.send('Welcome to my API!');
});

app.listen(3000, () => console.log('Server running on port 3000'));

3️⃣ 🌐 Express Middleware Example - Specific

Easily integrate with an Express API.

import express from 'express';
// ESM
import { RateLimiter, rateLimitMiddleware } from '@the-node-forge/api-rate-limit';
// or CommonJs
const {
  RateLimiter,
  rateLimitMiddleware,
} = require('@the-node-forge/api-rate-limit');

const app = express();

const limiterFiveReq = new RateLimiter({ windowMs: 60000, maxRequests: 5 });
const limiterTenReq = new RateLimiter({ windowMs: 60000, maxRequests: 10 });

// Apply rate limiting to only specific routes
app.get('/public', (req, res) => {
  res.send('This route has no rate limiting!');
});

// Apply rate limiting only to this route
app.get('/limited', rateLimitMiddleware(limiterFiveReq), (req, res) => {
  res.send('This route is rate-limited to 5 requests!');
});

app.post('/submit', rateLimitMiddleware(limiterTenReq), (req, res) => {
  res.send('This POST request is also rate-limited to ten requests!');
});

app.listen(3000, () => console.log('Server running on port 3000'));

API Reference

RateLimiter Class

new RateLimiter({ windowMs: number, maxRequests: number });

| Parameter | Type | Description | | ------------- | -------- | -------------------------------------------------------- | | windowMs | number | Time window in milliseconds (e.g., 60000 for 1 minute) | | maxRequests | number | Maximum allowed requests in the given window |

Methods

isAllowed(userId: string): boolean

| Method | Returns | Description | | ------------------- | --------- | --------------------------------------------------------------------------- | | isAllowed(userId) | boolean | Returns true if the user is allowed to make a request, otherwise false. |


💡 Contributing

Contributions are welcome! Please submit issues or pull requests.


⭐ Support

If you find this package useful, please **give it a ⭐ on GitHub


🔗 Links