-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
32 lines (26 loc) · 821 Bytes
/
index.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
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const fs = require('fs');
const expressConfig = require('./config/express');
const MysqlService = require('./services/MySQLService');
MysqlService.connect();
app.use(bodyParser.json());
require('./api')(app);
var sever = null;
if (expressConfig.useSSL) {
var credentials = {
key: fs.readFileSync(expressConfig.ssl.privateKey),
cert: fs.readFileSync(expressConfig.ssl.certificate)
};
server = require('https').createServer(credentials, app);
} else {
server = require('http').createServer(app);
}
server.listen(expressConfig.port, () => {
console.log('Server listening on port: ' + expressConfig.port);
});
process.on('SIGINT', function() {
MysqlService.disconnect();
process.exit();
});