From 26d6c3c4e3be6ccae81988734f2bdcf7076a872b Mon Sep 17 00:00:00 2001 From: Benjamin Kraft Date: Tue, 15 Nov 2022 09:39:40 +0100 Subject: [PATCH] server change --- package.json | 1 + src/index.ts | 11 ++++++----- tsconfig.json | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 4942cec..d0f4642 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "2.0", "private": true, "main": "out/index.js", + "types": "src/index.ts", "dependencies": { "dotenv": "^16.0.3", "https": "^1.0.0", diff --git a/src/index.ts b/src/index.ts index 3e3007b..f78e6c7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,13 +8,11 @@ import https = require('https'); import {Server} from 'socket.io'; import fs = require('fs'); -export function GameServer(){ - const p2p = require('socket.io-p2p-server').Server; - +export function GameServer(useP2P: boolean){ let rootDir = __dirname + '/..'; require("dotenv").config(); - const httpsPort = process.env["https_port"]; + const httpsPort = parseInt(process.env["HTTPS_PORT"]); let cert = fs.readFileSync(rootDir + '/ssl_certificate/cert.pem'); let key = fs.readFileSync(rootDir + '/ssl_certificate/key.pem'); @@ -26,7 +24,10 @@ export function GameServer(){ origin: ["https://play.benjamin-kraft.local", "https://dev.play.benjamin-kraft.eu", "https://play.benjamin-kraft.eu"] } }); - sIO.use(p2p); + if (useP2P){ + const p2p = require('socket.io-p2p-server').Server; + sIO.use(p2p); + } httpsServer.listen(httpsPort); diff --git a/tsconfig.json b/tsconfig.json index 480a0bf..ced65cf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es6", + "target": "ES2022", "module": "commonjs", "sourceMap": true, "alwaysStrict": true,