add some https for testing porpurses

This commit is contained in:
Leonard Anton Gläser
2022-01-11 17:13:28 +01:00
parent a9767da606
commit 4840394627
4 changed files with 850 additions and 1 deletions

View File

@ -1,11 +1,23 @@
import { ExpressPeerServer } from "peer";
import * as express from "express";
import * as fs from "fs";
import * as https from "https";
import * as path from "path";
const cert = fs.readFileSync(path.resolve(__dirname, "../cert/selfsigned.crt"), 'utf8');
const key = fs.readFileSync(path.resolve(__dirname, "../cert/selfsigned.key"), 'utf8');
var credentials = { key: key, cert: cert };
const app = express();
const server = app.listen(3000);
const https_server = https.createServer(credentials,app)
let server = https_server.listen(8001);
const peerServer = ExpressPeerServer(server, {
path: "/",
});
console.log("Started server!")
app.use("/peerjs", peerServer as any);
app.use("/", express.static("public"));