-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
41 lines (29 loc) · 1012 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
41
const express = require('express')
const dotenv = require('dotenv').config()
const http = require('http')
const path = require('path')
const bodyParser = require('body-parser')
const cors = require('cors')
const PORT = process.env.PORT || 5000
let app = express()
/*
let corsOptions = {
origin: "http://localhost:" + REACTPORT
}
*/
app.use(cors())
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
app.use(express.static(path.join(__dirname, 'build')))
app.use('/static', express.static(path.join(__dirname, 'public/uploads')))
const authAPI = require('./routes/auth-route')
app.use('/api/auth', authAPI)
const mealAPI = require('./routes/meal-routes')
app.use('/api/meals', mealAPI)
const userAPI = require('./routes/user-routes')
app.use('/api/users', userAPI)
app.get('/*', (req, res) => {
res.sendFile(path.join(__dirname, 'build', 'index.html'))
})
http.createServer(app).listen(PORT, "0.0.0.0", () => { console.log(`Listening on ${PORT}`)})
module.exports = app