forked from mecdcme/istatboard-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
46 lines (32 loc) · 1.1 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
34
35
36
37
38
39
40
41
42
43
44
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
app.use(bodyParser.json())
//upload photo
app.use(bodyParser.urlencoded({extended: true}));
app.use(function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:4200');
res.setHeader('Access-Control-Allow-Methods', 'POST');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
res.setHeader('Access-Control-Allow-Credentials', true);
next();
});
const cors = require('cors')
const corsOptions = {
origin: 'http://localhost:4200',
optionsSuccessStatus: 200
}
app.use(cors(corsOptions));
const db = require('./app/config/db.config.js');
// force: true will drop the table if it already exists
//db.sequelize.sync().then(() => {
// console.log('Drop and Resync with { force: true }');
// initial();
//});
require('./app/route/hack.route.js')(app);
// Create a Server
var server = app.listen(8080, function () {
//let host = server.address().address
let port = server.address().port
console.log("Server listening on port %s", port);
})