-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
29 lines (21 loc) · 822 Bytes
/
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
const express = require("express");
// const bodyParser = require("body-parser"); /* deprecated */
const cors = require("cors");
const app = express();
var db = require('./app/models');
var corsOptions = {
origin: "http://localhost:"+process.env.APP_PORT
};
app.use(cors(corsOptions));
// parse requests of content-type - application/json
app.use(express.json()); /* bodyParser.json() is deprecated */
// parse requests of content-type - application/x-www-form-urlencoded
app.use(express.urlencoded({ extended: true })); /* bodyParser.urlencoded() is deprecated */
// load application routes
require("./app/routes/index.js")(app);
// set port, listen for requests
const PORT = process.env.APP_PORT || 8080;
app.listen(PORT, () => {
db.sequelize.sync();
console.log(`Server is running on port ${PORT}.`);
});