Skip to content

0xRadioAc7iv/rate-limiter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rate Limiter 🚀

A lightweight and efficient rate-limiting library for Node.js, designed to help developers control API request rates and prevent abuse.

Features

  • ✅ In-memory, Redis & Mongo Support
  • ✅ Dynamic Rate Limiting
  • ✅ Supports Express, Fastify & NestJS

Setup

Installation

npm install @radioac7iv/rate-limiter

Usage

Basic example using Express:

import express from "express";
import { expressRateLimiter } from "@radioac7iv/rate-limiter";

const app = express();

const rateLimit = expressRateLimiter({
  limitOptions: () => {
    return { max: 5, window: 10 };
  },
});

app.use(rateLimit);

app.get("/", (request, response) => {
  response.status(200).send({ message: "Hello!" });
});

app.listen(3000, () => {
  console.log("Server started at PORT: 3000");
});

📖 Documentation

Detailed usage, configuration options, and examples are available in the official documentation:

Read the Docs

🤝 Contributing

Contributions are welcome! To get started:

  1. Fork the repository

  2. Clone your fork

  3. Install dependencies:

npm install
  1. Create a new branch:
git checkout -b feature-name
  1. Make your changes & commit:
git commit -m "Add new feature"
  1. Push & open a PR:
git push origin feature-name

Read the full Contribution Guidelines here

🧪 Testing

To run the tests:

cd package
npm test

To get coverage report:

npm run test:cov

📜 License

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