forked from northernfrontier/express
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
71 lines (49 loc) · 1.77 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const express = require("express");
// const bodyParser = require("body-parser"); /* deprecated */
const cors = require("cors");
const app = express();
// const bodyParser = require("body-parser");
const {spawn} = require("child_process");
const fs = require("fs");
const https = require('https');
const http = require('http');
const options = {
key: fs.readFileSync("app/config/star_ravnalaska_net.key"),
cert: fs.readFileSync("app/config/star_ravnalaska_net.crt"),
};
// var corsOptions = {
// // origin: "http://localhost:8080",
// origin: "http://localhost:8091",
// origin:"http://localhost:4200"
// };
app.use(cors());
// parse requests of content-type - application/json
app.use(express.json()); /* bodyParser.json() is deprecated */
// parse requests of content-type - application/x-www-form-urlencoded
app.use(express.urlencoded({ extended: true })); /* bodyParser.urlencoded() is deprecated */
// simple route
app.get("/", (req, res) => {
res.json({ message: "Welcome to New Stats Server." });
// res.sendFile(`${__dirname}/public/index.html`)
});
require("./app/routes/stats.routes.js")(app);
// set port, listen for requests
// const PORT = process.env.PORT || 8090;
// app.listen(PORT, () => {
// console.log(`Server is running on port ${PORT}.`);
// });
// app.use((req, res, next) => {
// res.send('<h1>HTTPS is working!</h1>');
// });
const secureport = 8443;
https.createServer(options, app).listen(secureport, () => {
console.log('Server listening on port ' + secureport);
});
const secureport2 = 443;
https.createServer(options, app).listen(secureport2, () => {
console.log('Server 2 listening on port ' + secureport2);
});
const port = 8077;
http.createServer(options, app).listen(port, () => {
console.log('Server listening on port ' + port);
});