-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
38 lines (36 loc) · 947 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const express = require("express");
const cors = require("cors");
require("./db/connection");
const cookieParser = require("cookie-parser");
const bodyParser = require("body-parser");
const routes = require("./routes/index");
const rateLimit = require("express-rate-limit");
const nodemailer = require("nodemailer");
require("dotenv").config();
const app = express();
app.use(bodyParser.json());
app.use(
bodyParser.urlencoded({
extended: true,
})
);
app.use(express.static("public"));
app.use(express.json());
const limiter = rateLimit({
windowMs: 1 * 60 * 1000, // 15 minutes
max: 50, // limit each IP to 100 requests per windowMs
});
app.use(limiter);
app.use(cors());
app.use(
express.urlencoded({
extended: true,
})
);
app.use(cookieParser());
app.use("/api", routes);
const port = process.env.PORT || 5000;
app.listen(port, (err) => {
if (err) console.log(err);
else console.log("Server started successfully");
});