From 40c03592dfd886f5e11305a0436374c3fd5a9de2 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Mon, 19 Sep 2022 17:40:57 +0300 Subject: [PATCH] LINXD-2222: Update --- app.js | 37 +++++++++++++++++++++++++------------ package.json | 1 - 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/app.js b/app.js index 5e2d5a8..34c7a9f 100644 --- a/app.js +++ b/app.js @@ -1,24 +1,35 @@ -import 'dotenv/config' - /** * integrating mediasoup server with a node.js application */ +require('dotenv').config() +const app = require('express')(); +const https = require('https'); +const path = require('node:path'); +const __dirname = path.resolve() +let https; +try { + https = require('node:https'); +} catch (err) { + console.log('https support is disabled!'); +} + +const mediasoup = require('mediasoup'); /* Please follow mediasoup installation requirements */ /* https://mediasoup.org/documentation/v3/mediasoup/installation/ */ -import express from 'express' -const app = express() +// import express from 'express' +// const app = express() // const app = require('express')(); // import https from 'httpolyglot' -import https from "https"; -import fs from 'fs' -import path from 'path' -const __dirname = path.resolve() +// import https from "https"; +// import fs from 'fs' +// import path from 'path' + // import Server from 'socket.io' -import mediasoup from 'mediasoup' +// import mediasoup from 'mediasoup' // import * as https from "http"; -import Server from "socket.io"; +// import Server from "socket.io"; // import middleware from 'socketio-wildcard' // const app = express.default(); @@ -55,8 +66,10 @@ const options = { cert: fs.readFileSync('./server/ssl/cert.pem', 'utf-8') } -const httpsServer = https.createServer(options, app); -const io = new Server(httpsServer, { allowEIO3: true }); +// const httpsServer = https.createServer(options, app); +// const io = new Server(httpsServer, { allowEIO3: true }); +const server = https.createServer(app); +const io = require('socket.io')(server, options); // const io = new Server(server, { origins: '*:*', allowEIO3: true }); // io.use(middleware); diff --git a/package.json b/package.json index 00e007c..1437aae 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,6 @@ "keywords": [], "author": "", "license": "ISC", - "type": "module", "dependencies": { "@types/express": "^4.17.13", "dotenv": "^16.0.1",