Merge branch 'dev' into prod
This commit is contained in:
+6
-5
@@ -4,7 +4,7 @@ import apiRouter from "./routes/api.js";
|
|||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const port = 7001;
|
const port = 7001;
|
||||||
import rateLimit from "express-rate-limit";
|
import { rateLimit } from "express-rate-limit";
|
||||||
|
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
app.use(express.urlencoded({ extended: true }));
|
app.use(express.urlencoded({ extended: true }));
|
||||||
@@ -13,14 +13,15 @@ app.use(express.json());
|
|||||||
|
|
||||||
const limits = {
|
const limits = {
|
||||||
time: 1, // = 1 minute
|
time: 1, // = 1 minute
|
||||||
requests: 10,
|
requests: 10, // = maximum 10 requests
|
||||||
message: "Too many requests from this IP, please try again in 15 minutes",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const limiter = rateLimit({
|
const limiter = rateLimit({
|
||||||
windowMs: limits.time * 60 * 1000,
|
windowMs: limits.time * 60 * 1000,
|
||||||
max: limits.requests,
|
limit: limits.requests,
|
||||||
message: limits.message,
|
standardHeaders: "draft-8", // draft-6: `RateLimit-*` headers; draft-7 & draft-8: combined `RateLimit` header
|
||||||
|
legacyHeaders: false, // Disable the `X-RateLimit-*` headers.
|
||||||
|
ipv6Subnet: 56, // Set to 60 or 64 to be less aggressive, or 52 or 48 to be more aggressive
|
||||||
});
|
});
|
||||||
|
|
||||||
app.use(limiter);
|
app.use(limiter);
|
||||||
|
|||||||
Reference in New Issue
Block a user