Compare commits
2 Commits
b7155a4ede
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| caa720352f | |||
| 2feef397df |
@@ -4,27 +4,12 @@ import env from "dotenv";
|
|||||||
env.config();
|
env.config();
|
||||||
const app = express();
|
const app = express();
|
||||||
const port = 7001;
|
const port = 7001;
|
||||||
import rateLimit from "express-rate-limit";
|
|
||||||
|
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
app.use(express.urlencoded({ extended: true }));
|
app.use(express.urlencoded({ extended: true }));
|
||||||
app.set("view engine", "ejs");
|
app.set("view engine", "ejs");
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
||||||
const limits = {
|
|
||||||
time: 1, // = 1 minute
|
|
||||||
requests: 10,
|
|
||||||
message: "Too many requests from this IP, please try again in 15 minutes",
|
|
||||||
};
|
|
||||||
|
|
||||||
const limiter = rateLimit({
|
|
||||||
windowMs: limits.time * 60 * 1000,
|
|
||||||
max: limits.requests,
|
|
||||||
message: limits.message,
|
|
||||||
});
|
|
||||||
|
|
||||||
app.use(limiter);
|
|
||||||
|
|
||||||
app.get("/", (req, res) => {
|
app.get("/", (req, res) => {
|
||||||
res.render("index.ejs", { title: port });
|
res.render("index.ejs", { title: port });
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user