-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (21 loc) · 818 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
const express = require('express')
const cors = require('cors');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const path = require('path');
const app = express()
const port = process.env.PORT || 8080
require('./config/db')
// bodyparser middleware
app.use(bodyParser.urlencoded({ limit:'50mb', extended: false }));
app.use(bodyParser.json({limit: '50mb', extended: false}));
app.use(cors());
// app.get('/', (req, res) => res.send('Hello World!'))
require('./route/routes')(app);
if (process.env.NODE_ENV === 'production'){
app.use(express.static('./client/build'))
app.get('/*', function(req, res) {
res.sendFile(path.join(__dirname, 'client/build', 'index.html'));
});
}
app.listen(port, () => console.log(`Example app listening on port ${port}!`))