New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ip-access-limiter

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ip-access-limiter

A simple, fast IP rate limiter for Express/Node with in-memory and Redis support.

latest
npmnpm
Version
0.0.0
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

IP Access Limiter

A simple and efficient IP access limiter middleware for Express/Node.js applications. This project provides a lightweight solution for limiting the number of requests from individual IP addresses, helping to prevent abuse and ensure fair usage of your API.

Features

  • In-memory and Redis support: Choose between an in-memory store for quick setups or a Redis-backed store for production environments.
  • Automatic IP blocking: Automatically block IP addresses that exceed the allowed request limits.
  • Real-time logs: Monitor blocked IPs and request counts in real-time.
  • Plug-and-play middleware: Easily integrate the rate limiter into your Express application with minimal setup.

Installation

To install IP Access Limiter, run the following command:

npm install ip-access-limiter

Usage

Basic Setup

  • Import the rate limiter middleware in your Express application:
import express from 'express';
import { rateLimiter } from 'ip-access-limiter';

const app = express();
const PORT = process.env.PORT || 3000;

// Apply the rate limiter middleware
app.use(rateLimiter({
    windowMs: 15 * 60 * 1000, // 15 minutes
    max: 100 // limit each IP to 100 requests per windowMs
}));

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

app.listen(PORT, () => {
    console.log(`Server is running on http://localhost:${PORT}`);
});

Configuration Options

You can customize the rate limiter by passing options to the middleware:

  • windowMs: The time window for which requests are checked (in milliseconds).
  • max: The maximum number of requests allowed per IP within the time window.
  • store: Optionally specify a custom store (e.g., RedisStore or MemoryStore).

Example Express Application

Refer to the example application located in the examples/express-app/app.ts file for a complete implementation.

Logging

The rate limiter includes a logging utility that can be configured to log events such as blocked IPs and request counts. You can customize the logging behavior in the src/utils/logger.ts file.

Testing

Unit tests for the rate limiter functionality can be found in the test/rateLimiter.test.ts file. To run the tests, use the following command:

npm test

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue for any enhancements or bug fixes.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Keywords

rate limiter

FAQs

Package last updated on 21 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts