hytopia 0.7.3-dev1 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bun-server.mjs +2 -2
- package/node-server.mjs +1 -1
- package/package.json +1 -1
package/node-server.mjs
CHANGED
|
@@ -457,7 +457,7 @@ qYGMwU/HBVHkLAn5XvT2a9xM0mzZ558d+ahbw8qAgRxg7BZ+2PW/bf7F2WRBUk1f
|
|
|
457
457
|
xauhAoGBALEspoxQozwohGQnP7EMF0/0JoKNpdNv0b0qCVvNiMo0+N297lI2mFQp
|
|
458
458
|
6xYlW/1l9afLokklF/J2IsyBrTCZoY7SaEk/lMMrQSyra+y0z71ogZ8A4ny9fxsj
|
|
459
459
|
0dDYJZGllL+3E/MQfd7k+KnOM/+A+cPoAnci76+L3vdkUb2P8SJk
|
|
460
|
-
-----END RSA PRIVATE KEY-----`;var B_=process.env.PORT??8080,w_="0.7.3
|
|
460
|
+
-----END RSA PRIVATE KEY-----`;var B_=process.env.PORT??8080,w_="0.7.3",O_;(($)=>{$.READY="WEBSERVER.READY";$.STOPPED="WEBSERVER.STOPPED";$.ERROR="WEBSERVER.ERROR";$.UPGRADE="WEBSERVER.UPGRADE"})(O_||={});class EW extends B0{static instance=new EW;_webserver=PO.default();_internalHttpServer;constructor(){super();this._webserver.use((Z,J,X)=>{J.header("Access-Control-Allow-Origin","*"),X()}),this._webserver.get("/",(Z,J)=>{J.json({status:"OK",version:w_,runtime:typeof Bun!=="undefined"?"bun":"node"})}),this._webserver.use(PO.default.static("assets"));try{this._webserver.use(PO.default.static(Tn1.dirname(g.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js"))))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?Pn1.createServer(this._webserver):Cn1.createServer({key:DO.existsSync("assets/certs/localhost.key")?DO.readFileSync("assets/certs/localhost.key"):aY0,cert:DO.existsSync("assets/certs/localhost.crt")?DO.readFileSync("assets/certs/localhost.crt"):nY0},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else u.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(B_,this._onStarted),console.info(`WebServer.start(): Server running on port ${B_}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return u.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let Y=En1.parse(Z.url??"",!0).query,$=Y.connectionId?.toString(),Q=Y.sessionToken?.toString()??"";if($&&A7.instance.isValidConnectionId($))Z.connectionId=$;else{let K=await M7.instance.getPlayerSession(Q);if(K?.error){let W=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
|
|
461
461
|
Content-Type: text/plain\r
|
|
462
462
|
Content-Length: ${W.length}\r
|
|
463
463
|
Connection: close\r
|
package/package.json
CHANGED