-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
36 lines (27 loc) · 765 Bytes
/
app.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
require('dotenv').config();
const express = require("express");
const mongoose = require("mongoose");
const cors = require("cors");
const app = express();
const PORT = process.env.PORT || 3000;
const authRoutes = require("./routes/auth");
const userRoutes = require("./routes/users");
app.use(express.json());
app.use(cors());
app.use(authRoutes);
app.use(userRoutes);
const rateLimit = require("express-rate-limit");
const authLimiter = rateLimit({
windowMs: 10 * 60 * 1000,
max: 5
});
app.use(authLimiter);
mongoose.connect(process.env.MONGODB, {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
useCreateIndex: true,
});
app.listen(PORT, () => {
console.log(`Server listening on port: ${PORT}`);
});