-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
60 lines (41 loc) · 1.29 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const express = require('express');
const colors = require('colors');
const path = require('path');
const bodyParser = require('body-parser'); //parsing incoming request
const cors = require('cors');
const passport = require('passport');
const server_response = require('./response/serverResponse');
var app = express();
//PORT
const port = process.env.PORT || 8423;
// Cross Origin Resource Sharing Middleware
app.use(cors());
//set Static Folder (Public)
app.use(express.static(path.join(__dirname, 'public')));
//Body Parser Middleware
app.use(bodyParser.json());
const api = require('./routes/api');
//api endpoints
app.use('/api', api);
app.use(passport.initialize());
app.use(passport.session());
require('./config/passport')(passport);
app.get('/', (req, res) => {
res.send('Wrong Endpoint');
});
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'public/index.html'));
});
var http = require('http').createServer(app);
var io = require('socket.io')(http);
require('./sockets/sockets')(io);
http.listen(port, function () {
server_response.startServer(port);
require('./businesslogics/aerolinkserver').establishedLogDBServer();
});
http.on('close', function () {
server_response.closeServer();
})
http.on('error', function (err) {
server_response.errorServer(err);
})