Simple rate-limiter NPM Module used for blocking IPs that exceeds certain number of requests per second in a specific time frame.

Overview

API Rate Limiter

Zero-Dependencies Simple rate-limiter NPM Module used for blocking IPs that exceeds certain number of requests per second in a specific time frame.

https://www.npmjs.com/package/@ahmedkhaled1444/rate-limiter

Installation

    npm i @ahmedkhaled1444/rate-limiter

How it works

const rateLimiter = require("@ahmedkhaled1444/rate-limiter");
app.use(
  rateLimit({
    timeLimit: 60,
    maxRequestsPerSecond: 70,
    maxRequestsPerFrame: 1000,
    statusCode: 429,
    message: "Too many requests, please try again later",
    responseHeaders: true,
  })
);

Options

timeLimit

  • Type: Number
  • Default: 60
  • Description: The time frame in seconds to check the number of requests.
  • Set to 0 to disable the rate limiter.

maxRequestsPerSecond

  • Type: Number
  • Default: 5
  • Description: The maximum number of requests per second.
  • Set to 0 to disable the rate limiter.

maxRequestsPerFrame

  • Type: Number
  • Default: 100
  • Description: The maximum number of requests per time frame.
  • Set to 0 to disable the rate limiter.

statusCode

  • Type: Number
  • Default: 429
  • Description: The status code to send when the request is blocked.

message

  • Type: String
  • Default: Too many requests.
  • Description: The message to send when the request is blocked.

responseHeaders

  • Type: Boolean
  • Default: true
  • Description: If set to true, the response will contain the following headers:
    • X-RateLimit-Limit: The maximum number of requests per time frame.
    • X-RateLimit-Remaining: The remaining number of requests per time frame.
    • X-RateLimit-Reset: The time frame in seconds.
  • If set to false, the response will not contain any of the above headers.
You might also like...

I Built This project in microverse's second module, in this single web application the user Can add, remove and display the list of books.

Awsome Books I Built This project in microverse's second module, in this single web application the user Can add, remove and display the list of books

Aug 3, 2022

Multiplies a number by zero. Useful for when you need to multiply a number by zero

multiply-by-zero Multiplies a number by zero. Useful for when you need to multiply a number by zero Please consider checking out the links of this pro

Jul 3, 2022

Demodal is a browser extension that automatically removes content blocking modals including paywalls, discount offers, promts to sign up or enter your email address and more.

Demodal Demodal is a browser extension that automatically removes content blocking modals including paywalls, discount offers, promts to sign up or en

Jan 4, 2023

Automaticly parses known pocket ips patch resources, scans folders or zip files for matching roms and applies the patches.

Pocket Automaton Automaticly parses known pocket ips patch resources, scans folders or zip files for matching roms and applies the patches. Usage pock

Nov 27, 2022

Demo running web assembly apps a terminal with blocking stdin/stdout/stderr

Python wasm-terminal Live version here: https://wasm-terminal.firebaseapp.com/ This is a small demo of running Python in the browser with a focus on i

Nov 16, 2022

to choose the best one of Gcore‘IPs for connection with lowest latency.

GcoreCDNIPSelector to choose the best IP from Gcore-CDN to reach the lowest latency and stable connections. Background Gcore's CDN provide a smooth ex

Nov 5, 2022

A-Frame Element is a simple library for building fast, lightweight web components for 3D development

A-Frame Element is a simple library for building fast, lightweight web components for 3D development

aframe-element is a library inspired from the very nice library Polymer lit to map A-Frame AR / VR / 3D elements on typescript classes like Angular/React/Lit.

May 31, 2022

🪨 A simple obsidian plugin that links all modified files meeting certain criteria to a daily note

🪨 A simple obsidian plugin that links all modified files meeting certain criteria to a daily note

Obsidian List Modified This plugin lists all modified files meeting certain criteria to a daily note. Why? As of now, dataview queries cannot be "froz

Dec 7, 2022

Make sure a specific version and package-manger to be used in project.

pm-keeper A simple way to force package-manager in your project. usage Add a preinstall script in your project's package.json, link this: { "scripts

Sep 25, 2022
Owner
Khaldon
Khaldon
Një projekt open source për komunitetin që shërben për të gjeneruar fjalëkalime me nivele të sigurisë të ndryshme.

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Benjamin Fazli 4 Mar 7, 2022
An npm package for demonstration purposes using TypeScript to build for both the ECMAScript Module format (i.e. ESM or ES Module) and CommonJS Module format. It can be used in Node.js and browser applications.

An npm package for demonstration purposes using TypeScript to build for both the ECMAScript Module format (i.e. ESM or ES Module) and CommonJS Module format. It can be used in Node.js and browser applications.

Snyk Labs 57 Dec 28, 2022
A complete media query framework for CSS, to apply specific properties in specific screen

A complete media query framework for CSS, to apply specific properties in specific screen Note: Size of every media query is `50px, 100px, 150px, 200p

Rohit Chouhan 6 Aug 23, 2022
npm i uuid, npm i nodemon, npm i commander

goit-nodejs-hw-01 Получаем и выводим весь список контактов в виде таблицы (console.table) node index.js --action list Получаем контакт по id node inde

Oksana Banshchykova 3 Jul 5, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
jquery-input-mask-phone-number.js - A simple, easy jquery format phone number mask library

jquery-input-mask-phone-number A jQuery Plugin to make masks on input field to US phone format. Quick start 1. Add latest jQuery and jquery-input-mask

Raja Rama Mohan Thavalam 12 Aug 25, 2022
This application lists the scores of players of a certain game (determined by the user), in this app the Leaderboard REST API is used, where the participants and their scores are registered.

Leaderboard this application lists the scores of players of a certain game (determined by the user), in this app the Leaderboard REST API is used, whe

Gonzalo Medina 5 Jul 29, 2022