No seriously, fix the rest api since relocating the helper methods caused issues

pull/9520/head
Bradley Hilton 8 years ago
parent 1264813176
commit 77cd43e5a6
No known key found for this signature in database
GPG Key ID: 0666B2C24C43C358
  1. 13
      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;
}

Loading…
Cancel
Save