forked from hibas123/ScreenSharingThing
24 lines
688 B
TypeScript
24 lines
688 B
TypeScript
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 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"));
|