Skip to content

Commit

Permalink
Refactored rate limiter
Browse files Browse the repository at this point in the history
  • Loading branch information
IGuy37 committed Jul 8, 2024
1 parent 193f1af commit 47b2c7b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ app.use(express.json());
app.use(cors());

// set up rate limiter: maximum of 60 requests per minute
const maxRequests = 60;
const numSeconds = 60;
const limiter = RateLimit({
windowMs: 60 * 1000, // 1 minute
max: 60, // max 5 requests per windowMs
windowMs: numSeconds * 1000, // 1000 milliseconds = 1 second
max: maxRequests,
});

// apply rate limiter to all requests
Expand Down

0 comments on commit 47b2c7b

Please sign in to comment.