other refactors

This commit is contained in:
srgooglo 2021-07-08 15:24:06 +02:00
parent 56099604eb
commit 0a25a3fe0e
2 changed files with 8 additions and 8 deletions

View File

@ -22,7 +22,7 @@ class Bridge {
}
function generateRouteDispatcher(bridge, method, route, getContext) {
return async function (body, query, ...context){
return async function (body, query, ...context) {
let obj = Object()
let opt = {
method: method,
@ -33,13 +33,13 @@ function generateRouteDispatcher(bridge, method, route, getContext) {
}
if (typeof getContext === "function") {
opt = {...opt, ...getContext()}
opt = { ...opt, ...getContext() }
}
const response = await bridge.instance(opt)
obj = response.data
obj.__proto__ = response
const req = await bridge.instance(opt)
obj = req.data
obj.__proto__ = req
return obj
}

View File

@ -43,7 +43,7 @@ class Server {
this.routes = []
this.endpoints = {}
this.serverMiddlewares = [...this.params.serverMiddlewares ?? [], ...defaultMiddlewares]
this.middlewares = {...this.params.middlewares}
this.middlewares = { ...this.params.middlewares }
this.controllers = { ...this.params.controllers }
this.headers = { ...defaultHeaders, ...this.params.headers }
@ -108,7 +108,7 @@ class Server {
query.push(endpoint.middleware)
}
if (Array.isArray(endpoint.middleware)) {
query = endpoint.middleware
query = endpoint.middleware
}
query.forEach((middleware) => {