From 77cd43e5a6f6e7f0e878ec8a2875c8c19fe9573f Mon Sep 17 00:00:00 2001 From: Bradley Hilton Date: Wed, 31 Jan 2018 15:51:13 -0600 Subject: [PATCH] No seriously, fix the rest api since relocating the helper methods caused issues --- packages/rocketchat-api/server/api.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/rocketchat-api/server/api.js b/packages/rocketchat-api/server/api.js index 652506ef3b9..230ef520f1a 100644 --- a/packages/rocketchat-api/server/api.js +++ b/packages/rocketchat-api/server/api.js @@ -5,7 +5,6 @@ class API extends Restivus { constructor(properties) { super(properties); this.logger = new Logger(`API ${ properties.version ? properties.version : 'default' } Logger`, {}); - this.helperMethods = new Map(RocketChat.API.helperMethods); this.authMethods = []; this.fieldSeparator = '.'; this.defaultFieldsToExclude = { @@ -51,6 +50,14 @@ class API extends Restivus { }; } + hasHelperMethods() { + return RocketChat.API.helperMethods.size !== 0; + } + + getHelperMethods() { + return RocketChat.API.helperMethods; + } + addAuthMethod(method) { this.authMethods.push(method); } @@ -121,7 +128,7 @@ class API extends Restivus { routes.forEach((route) => { //Note: This is required due to Restivus calling `addRoute` in the constructor of itself - if (this.helperMethods) { + if (this.hasHelperMethods()) { Object.keys(endpoints).forEach((method) => { if (typeof endpoints[method] === 'function') { endpoints[method] = {action: endpoints[method]}; @@ -155,7 +162,7 @@ class API extends Restivus { return result; }; - for (const [name, helperMethod] of this.helperMethods) { + for (const [name, helperMethod] of this.getHelperMethods()) { endpoints[method][name] = helperMethod; }