use Hyper-Express lib

This commit is contained in:
srgooglo 2022-05-05 09:45:28 +02:00
parent d4002163af
commit a68cdb1ffe

View File

@ -2,7 +2,7 @@ const path = require("path")
const fs = require("fs") const fs = require("fs")
const net = require("corenode/net") const net = require("corenode/net")
const http = require("nanoexpress") const HyperExpress = require("hyper-express")
const io = require("socket.io") const io = require("socket.io")
const packageJSON = require(path.resolve(module.path, "../../package.json")) const packageJSON = require(path.resolve(module.path, "../../package.json"))
@ -26,7 +26,6 @@ global.DEFAULT_HEADERS = {
} }
const defaultMiddlewares = [ const defaultMiddlewares = [
require("@nanoexpress/middleware-body-parser/cjs")(),
require('cors')({ require('cors')({
"origin": "*", "origin": "*",
"methods": DEFAULT_HEADERS["Access-Control-Allow-Methods"], "methods": DEFAULT_HEADERS["Access-Control-Allow-Methods"],
@ -59,7 +58,7 @@ class Server {
this.WSAddress = `ws://${LOCALHOST_ADDRESS}:${this.WSListenPort}` this.WSAddress = `ws://${LOCALHOST_ADDRESS}:${this.WSListenPort}`
//* set server basics //* set server basics
this.httpInterface = global.httpInterface = http() this.httpInterface = global.httpInterface = new HyperExpress.Server()
this.wsInterface = global.wsInterface = { this.wsInterface = global.wsInterface = {
io: new io.Server(this.WSListenPort), io: new io.Server(this.WSListenPort),
map: {}, map: {},
@ -120,7 +119,7 @@ class Server {
// initialize http server // initialize http server
await this.httpInterface.listen(this.HTTPlistenPort, this.params.listen ?? "0.0.0.0") await this.httpInterface.listen(this.HTTPlistenPort, this.params.listen ?? "0.0.0.0")
console.log(` Ready on port ${this.HTTPlistenPort}!`) console.log(`Server is up and running!`)
} }
handleWSClientConnection = async (socket) => { handleWSClientConnection = async (socket) => {