From 70e319665a50e7b935e67eb8a76906537402e32b Mon Sep 17 00:00:00 2001 From: srgooglo Date: Fri, 6 May 2022 08:09:21 +0200 Subject: [PATCH] comments over `registerHTTPEndpoint` --- src/server/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/server/index.js b/src/server/index.js index 990e437..766eee2 100755 --- a/src/server/index.js +++ b/src/server/index.js @@ -174,16 +174,19 @@ class Server { endpoint.method = FixedMethods[endpoint.method] } + // grab the middlewares let middlewares = [...execs] if (endpoint.middlewares) { middlewares = [...middlewares, ...this.resolveMiddlewares(endpoint.middlewares)] } + // make sure method has root object on endpointsMap if (typeof this.endpointsMap[endpoint.method] !== "object") { this.endpointsMap[endpoint.method] = {} } + // extend to map this.endpointsMap[endpoint.method] = { ...this.endpointsMap[endpoint.method], [endpoint.route]: { @@ -192,6 +195,7 @@ class Server { }, } + // set handler this.httpInterface[endpoint.method](endpoint.route, ...middlewares, this.handleHTTPRequest) }