mirror of
https://github.com/ragestudio/linebridge.git
synced 2025-06-09 18:44:17 +00:00
commit
8e6f223882
@ -19,16 +19,18 @@
|
|||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"socket.io": "^4.2.0",
|
|
||||||
"@corenode/helpers": "^0.28.18",
|
"@corenode/helpers": "^0.28.18",
|
||||||
"@corenode/utils": "^0.28.18",
|
"@corenode/utils": "^0.28.18",
|
||||||
"corenode": "^0.28.18",
|
|
||||||
"axios": "^0.22.0",
|
"axios": "^0.22.0",
|
||||||
|
"body-parser": "^1.19.0",
|
||||||
|
"corenode": "^0.28.18",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"md5": "^2.3.0",
|
"md5": "^2.3.0",
|
||||||
"morgan": "^1.10.0",
|
"morgan": "^1.10.0",
|
||||||
|
"nanoexpress": "^5.1.2",
|
||||||
"nanoid": "^3.1.28",
|
"nanoid": "^3.1.28",
|
||||||
|
"socket.io": "^4.2.0",
|
||||||
"uuid": "^8.3.2",
|
"uuid": "^8.3.2",
|
||||||
"websocket": "^1.0.34"
|
"websocket": "^1.0.34"
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
const fs = require("fs")
|
const fs = require("fs")
|
||||||
const express = require("express")
|
const http = require("nanoexpress")
|
||||||
|
const bodyParser = require('body-parser')
|
||||||
|
|
||||||
const { nanoid } = require("nanoid")
|
const { nanoid } = require("nanoid")
|
||||||
const tokenizer = require("corenode/libs/tokenizer")
|
const tokenizer = require("corenode/libs/tokenizer")
|
||||||
@ -47,8 +48,7 @@ class Server {
|
|||||||
this.headers = { ...defaultHeaders, ...this.params.headers }
|
this.headers = { ...defaultHeaders, ...this.params.headers }
|
||||||
|
|
||||||
//* set server basics
|
//* set server basics
|
||||||
this.httpServer = require("express")()
|
this.httpServer = http()
|
||||||
this.router = express.Router()
|
|
||||||
|
|
||||||
//* set id's
|
//* set id's
|
||||||
this.id = this.params.id ?? process.runtime?.helpers?.getRootPackage()?.name ?? "unavailable"
|
this.id = this.params.id ?? process.runtime?.helpers?.getRootPackage()?.name ?? "unavailable"
|
||||||
@ -178,13 +178,13 @@ class Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// append to router
|
// append to router
|
||||||
this.router[controller.method](...routeModel)
|
this.httpServer[controller.method](...routeModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
preInitialization() {
|
preInitialization() {
|
||||||
// set middlewares
|
// set middlewares
|
||||||
this.httpServer.use(express.json())
|
this.httpServer.use(bodyParser.json())
|
||||||
this.httpServer.use(express.urlencoded({ extended: true }))
|
this.httpServer.use(bodyParser.urlencoded({ extended: true }))
|
||||||
|
|
||||||
if (Array.isArray(this.serverMiddlewares)) {
|
if (Array.isArray(this.serverMiddlewares)) {
|
||||||
this.serverMiddlewares.forEach((middleware) => {
|
this.serverMiddlewares.forEach((middleware) => {
|
||||||
@ -251,7 +251,7 @@ class Server {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init = async () => {
|
||||||
// write lastStart
|
// write lastStart
|
||||||
serverManifest.write({ lastStart: Date.now() })
|
serverManifest.write({ lastStart: Date.now() })
|
||||||
|
|
||||||
@ -268,16 +268,14 @@ class Server {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
this.httpServer.use('/', this.router)
|
await this.httpServer.listen(this.port, this.params.listen ?? '0.0.0.0')
|
||||||
|
|
||||||
this.httpServer.listen(this.port, this.params.listen ?? '0.0.0.0', () => {
|
|
||||||
//? register to nethub
|
//? register to nethub
|
||||||
if (this.params.onlineNethub) {
|
if (this.params.onlineNethub) {
|
||||||
nethub.registerOrigin({ entry: "/", oskid: this.oskid, id: this.id })
|
nethub.registerOrigin({ entry: "/", oskid: this.oskid, id: this.id })
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`✅ Ready on port ${this.port}!`)
|
console.log(`✅ Ready on port ${this.port}!`)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user