-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (30 loc) · 1.03 KB
/
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
33
34
35
36
37
38
39
require('dotenv').config();
const express = require('express');
const cors = require('cors');
const app = express();
const bodyParser = require("body-parser");
const routes = require('./routes');
const fs = require('fs');
const https = require('https');
const path = require('path');
const MySQLBackend = require('./services/MySQL');
app.use(cors());
app.use(express.json());
app.use('/api', routes());
app.use(bodyParser.json());
app.use('/', express.static(path.join(__dirname, '..', 'client')));
const httpsOptions = {
cert: fs.readFileSync(path.join(__dirname, 'cert', 'cert.pem')),
key: fs.readFileSync(path.join(__dirname, 'cert', 'key.pem'))
};
const port = process.env.APP_PORT || 3443;
const runMySQL = async () => {
const mysqlBackend = new MySQLBackend();
return mysqlBackend.max();
}
runMySQL();
https.createServer(httpsOptions, app).listen(port, () => console.log('Server up and working... on port ', port));
/* app.listen(port, () => {
console.log('Server up and working... on port ', port);
}); */
module.exports = app;