mirror of
https://github.com/ragestudio/linebridge.git
synced 2025-06-09 18:44:17 +00:00
other refactors
This commit is contained in:
parent
56099604eb
commit
0a25a3fe0e
@ -22,7 +22,7 @@ class Bridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function generateRouteDispatcher(bridge, method, route, getContext) {
|
function generateRouteDispatcher(bridge, method, route, getContext) {
|
||||||
return async function (body, query, ...context){
|
return async function (body, query, ...context) {
|
||||||
let obj = Object()
|
let obj = Object()
|
||||||
let opt = {
|
let opt = {
|
||||||
method: method,
|
method: method,
|
||||||
@ -33,13 +33,13 @@ function generateRouteDispatcher(bridge, method, route, getContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof getContext === "function") {
|
if (typeof getContext === "function") {
|
||||||
opt = {...opt, ...getContext()}
|
opt = { ...opt, ...getContext() }
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await bridge.instance(opt)
|
const req = await bridge.instance(opt)
|
||||||
|
|
||||||
obj = response.data
|
obj = req.data
|
||||||
obj.__proto__ = response
|
obj.__proto__ = req
|
||||||
|
|
||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ class Server {
|
|||||||
this.routes = []
|
this.routes = []
|
||||||
this.endpoints = {}
|
this.endpoints = {}
|
||||||
this.serverMiddlewares = [...this.params.serverMiddlewares ?? [], ...defaultMiddlewares]
|
this.serverMiddlewares = [...this.params.serverMiddlewares ?? [], ...defaultMiddlewares]
|
||||||
this.middlewares = {...this.params.middlewares}
|
this.middlewares = { ...this.params.middlewares }
|
||||||
this.controllers = { ...this.params.controllers }
|
this.controllers = { ...this.params.controllers }
|
||||||
this.headers = { ...defaultHeaders, ...this.params.headers }
|
this.headers = { ...defaultHeaders, ...this.params.headers }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user