Skip to content

Commit

Permalink
Add rate limit
Browse files Browse the repository at this point in the history
  • Loading branch information
LackyPal authored Jun 23, 2023
1 parent f479e9e commit ebbc1aa
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ app.set("view engine", "ejs");
app.set("views", __dirname + "/views");
app.use(express.static(__dirname + "/public"));

// set up rate limiter: maximum of ten requests per minute
const RateLimit = require("express-rate-limit");
const limiter = RateLimit({
windowMs: 1*60*1000, // 1 minute
max: 10
});
// apply rate limiter to all requests
app.use(limiter);

// Routes
app.get("/", (req, res) => {
res.render("index", { error: null });
Expand Down

0 comments on commit ebbc1aa

Please sign in to comment.