mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-20 07:05:05 -04:00
Add rate limits
This commit is contained in:
parent
b3dff8a864
commit
aa38ae2a28
3 changed files with 465 additions and 0 deletions
12
index.js
12
index.js
|
@ -27,10 +27,22 @@ process.on('unhandledRejection', (reason, promise) => {
|
|||
})
|
||||
|
||||
const express = require('express');
|
||||
const RateLimit = require('express-rate-limit');
|
||||
const http = require('http');
|
||||
|
||||
const limiter = RateLimit({
|
||||
windowMs: 5 * 60 * 1000, // 5 minutes
|
||||
max: 100, // Limit each IP to 100 requests per `window` (here, per 5 minutes)
|
||||
message: 'Too many requests from this IP Address, please try again after 5 minutes.',
|
||||
standardHeaders: true, // Return rate limit info in the `RateLimit-*` headers
|
||||
legacyHeaders: false, // Disable the `X-RateLimit-*` headers
|
||||
})
|
||||
|
||||
const app = express();
|
||||
const port = process.env.PORT || 3000;
|
||||
|
||||
app.use(limiter);
|
||||
|
||||
app.use(express.static('public'));
|
||||
|
||||
app.use(function(req, res) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue