-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
29 lines (27 loc) · 807 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
'use strict';
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const app = express();
const db = require('./models');
require('./associations/associations')();
var corsOption = {
origin: true,
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
credentials: true,
allowedHeaders: ['Content-Type', 'Authorization'],
exposedHeaders: ['Content-Type', 'Authorization']
};
app.use(cors(corsOption));
const config = require('./config/serverConfig.json');
app.use(bodyParser.json());
require('./routes')(app);
db.sequelize.sync({force: false})
. then(() => {
console.log('table generated');
})
. catch((err) => console.log(err));
app.listen(
config.serverPort,
() => console.log(`Example app listening on port ${config.serverPort}!`)
);