-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
36 lines (27 loc) · 919 Bytes
/
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
const express = require("express");
const fs = require("fs");
const https = require("https");
const app = express();
const bodyParser = require("body-parser");
app.use(bodyParser.json());
const cors = require("cors");
const corsOptions = {
origin: "*",
optionsSuccessStatus: 200,
};
app.use(cors(corsOptions));
require("./app/routes/customer.route")(app);
const httpsOptions = {
key: fs.readFileSync("./ssl/server.key"), // путь к ключу
cert: fs.readFileSync("./ssl/server.crt"), // путь к сертификату
};
const ssl_server = https.createServer(httpsOptions, app).listen(8443, () => {
const { port } = ssl_server.address();
console.log("App listening the", port);
});
// Create a Server
const server = app.listen(8081, () => {
const { address: host } = server.address();
const { port } = server.address();
console.log("App listening at http://%s:%s", host, port);
});