-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
33 lines (31 loc) · 1.05 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
const express = require('express')
const app = express()
const path = require('path')
const logger = require('./middleware/logger')
const indexRoutes = require('./routes/index.js')
const homeRoutes = require('./routes/home.js')
const foodRoutes = require('./routes/food.js')
const cardioRoutes = require('./routes/cardio.js')
const strengthRoutes = require('./routes/strength.js')
const weightRoutes = require('./routes/weight.js')
const signup2Routes = require('./routes/signup2.js')
const mongoose = require('mongoose')
const bodyParser = require('body-parser')
const PORT = process.env.PORT || 5000
var dbUrl = 'mongodb://localhost:27017/fitnessfriend'
mongoose.connect(dbUrl, {useNewUrlParser: true})
app.use(logger)
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(express.static(path.join(__dirname, 'public')))
app.set('view engine', 'ejs')
indexRoutes(app)
homeRoutes(app)
foodRoutes(app)
cardioRoutes(app)
strengthRoutes(app)
weightRoutes(app)
signup2Routes(app)
app.listen(PORT, console.log(`Server started ${PORT}`))