1.1.0 • Published 5 years ago
webux-limiter v1.1.0
Webux Limiter
This module is wrapper for express-rate-limit, it creates limiter and they are apply using app.use()
Installation
npm i --save webux-limiter
Usage
const webuxlimiter = require("webux-limiter");
const express = require("express");
const app = express();
const AuthOptions = {
time: 3600, // blocked for 1 hour
maxReq: 3, // after 3 tries
skip: "/auth" // only for the route that start by
};
const GlobalOptions = {
time: 60, // blocked for 1 minute
maxReq: 5 // after 5 tries
};
const AuthLimiter = webuxlimiter.createLimiter(AuthOptions);
const GlobalLimiter = webuxlimiter.createLimiter(GlobalOptions);
app.use(AuthLimiter);
app.use(GlobalLimiter);
app.get("/", (req, res) => {
res.status(200).json({ msg: "Bonjour !" });
});
app.get("/auth/login", (req, res) => {
res.status(200).json({ msg: "Logged in !" });
});
app.get("/auth/register", (req, res) => {
res.status(200).json({ msg: "registered !" });
});
app.listen(1337);
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
License
SEE LICENSE IN license.txt
1.1.0
5 years ago