-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (31 loc) · 943 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
39
40
import express from 'express';
import mongoose from 'mongoose';
import bodyParser from 'body-parser';
import routes from './src/routes/crmRoutes';
import helmet from 'helmet';
import RateLimit from 'express-rate-limit';
const app = express();
const PORT = 3000;
// mongoose connection
mongoose.Promise = global.Promise;
mongoose.connect('mongodb://localhost/CRMdb');
// Express-rate-limit setup
const limiter = new RateLimit({
windowMs: 15*60*1000, // 15 minutes
max: 100, // limits number of requests
delayMs: 0 // disable delays
});
//helmet setup
app.use(helmet());
// bodyparser setup
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
routes(app);
// serving static files
app.use(express.static('public'));
app.get('/', (req, res) =>
res.send(`Node and express server is running on port ${PORT}`)
);
app.listen(PORT, () =>
console.log(`your server is running on port ${PORT}`)
);