-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
50 lines (38 loc) · 1.29 KB
/
server.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
39
40
41
42
43
44
45
46
47
48
49
50
const path = require('path');
const express = require('express');
const dotenv = require('dotenv');
const color = require('colors');
const rateLimit = require('express-rate-limit');
const helmet = require('helmet');
const xss = require('xss-clean');
const hpp = require('hpp');
const cors = require('cors');
const cookieParser = require('cookie-parser');
dotenv.config({ path: './config/config.env' });
const auth = require('./routes/auth');
const users = require('./routes/users');
const sports = require('./routes/sports');
const lectures = require('./routes/lectures');
const cashes = require('./routes/cashes');
const reservations = require('./routes/reservations');
const app = express();
app.use(express.json());
app.use(cookieParser());
app.use(helmet());
app.use(xss());
app.use(cors());
const limiter = rateLimit({
windowMs: 10 * 60 * 1000, // 10 mins
max: 100
});
app.use(limiter);
app.use(hpp());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/api/v1/auth', auth);
app.use('/api/v1/users', users);
app.use('/api/v1/sports', sports);
app.use('/api/v1/lectures', lectures);
app.use('/api/v1/cashes', cashes);
app.use('/api/v1/reservations', reservations);
const port = process.env.PORT || 5000;
app.listen(port, () => console.log(`Server running on port ${port}`.yellow.bold));