-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
38 lines (32 loc) · 1010 Bytes
/
app.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
const express = require('express');
const cookieParser = require('cookie-parser');
const cors = require("cors");
const morgan = require('morgan'); // Loger middleware
const helmet = require('helmet'); // Basic security patcher for express webserver
const bodyParser = require('body-parser'); // Parse incomming request body from express
const app = express();
app.use(cookieParser());
const corsOptions = {
//origin: 'http://localhost:8082',
optionsSuccessStatus: 200,
//credentials: true
}
app.use(cors(corsOptions));
app.use(morgan('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(helmet());
// Loads database, ensure is running
let db = require('./models/index');
let seqModels = require('./models/models');
(async () => {
await seqModels.synchronize();
})();
// Main routing
require('./routes')(app);
// Running app
const port = process.env.PORT || 8081;
app.listen(port, () => {
console.log("Server is running.");
});
module.exports = {app}