-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
36 lines (29 loc) · 1.03 KB
/
Copy pathserver.js
File metadata and controls
36 lines (29 loc) · 1.03 KB
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
const express = require('express')
const cors = require('cors')
const app = express()
const bodyParser = require('body-parser')
const Food = require('./lib/models/food.js')
var corsOptions = {
origin:'*',
optionsSuccessStatus: 200
}
app.use(cors(corsOptions))
app.options('*', cors(corsOptions))
app.set('port', process.env.PORT || 3000)
// Controllers
var readController = require('./lib/controllers/readController')
var createController = require('./lib/controllers/createController')
var updateController = require('./lib/controllers/updateController')
var destroyController = require('./lib/controllers/destroyController')
app.set('port', process.env.PORT || 3000)
// Fire off Controllers
readController(app, bodyParser, Food)
createController(app, bodyParser, Food)
updateController(app, bodyParser, Food)
destroyController(app, bodyParser, Food)
if(!module.parent){
app.listen(app.get("port"), () => {
console.log(`${app.locals.title} is running on port ${app.get('port')}.`)
})
}
module.exports = app;