-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathserver.ts
More file actions
24 lines (19 loc) · 721 Bytes
/
server.ts
File metadata and controls
24 lines (19 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import fs from "fs";
import http from "http";
import https from "https";
import express from "express";
const privateKey = fs.readFileSync("ssl/server.pem", "utf8");
const certificate = fs.readFileSync("ssl/server.pem", "utf8");
const credentials = { key: privateKey, cert: certificate };
const app = express();
const HTTP_PORT = 8080;
const HTTPS_PORT = 8443;
app.use(express.static("."));
const httpServer = http.createServer(app);
const httpsServer = https.createServer(credentials, app);
httpServer.listen(HTTP_PORT, () => {
console.log("Server listening on http://127.0.0.1:%d", HTTP_PORT);
});
httpsServer.listen(HTTPS_PORT, () => {
console.log("Server listening on https://127.0.0.1:%d", HTTPS_PORT);
});