Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

You can use this package to prevent continuous requests to APIs you write with Express.js within a certain period of time.

License

Notifications You must be signed in to change notification settings

ahmetilhn/express-ip-blocker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Express IP Blocker

You can use this package to prevent continuous requests to APIs you write with Express.js within a certain period of time.

Instalation

package (yarn or npm)

    npm install express-ip-blocker

PeerDependencies Optimum versions

    "cookie-parser": "^1.4.6",
    "express": "^4.18.2"

Usage

const express = require("express");
const app = express();
const cookieParser = require("cookie-parser");
const ExpressIPBlocker = require("express-ip-blocker-current");
const expressIPBlocker = new ExpressIPBlocker();
// You have to do this for the package to work
app.use(cookieParser());
// IP Middleware
app.use(expressIPBlocker.checkIP);

app.listen(//port, () => {
  //
});

See demo for example usage. ./demo/index.js

Config

You can apply a config to the package's run settings

{
  limit: number; // default = 10
  secretKey: string; // default = now Date()
  reqBlockMessage: string; // default = Too Many Requests
  expire: number; // default = 1000 * 10 -> 10 second
}

Coded by ahmetilhan

About

You can use this package to prevent continuous requests to APIs you write with Express.js within a certain period of time.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published