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) { 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
} }

View File

@ -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 }