From 62461ad3384724e71f7a25396d803189333d7313 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 16 Mar 2018 15:38:38 +0200 Subject: [PATCH] refactor(rest) early return --- server/rest/index.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/server/rest/index.js b/server/rest/index.js index 4d6404d2..b9eb817d 100644 --- a/server/rest/index.js +++ b/server/rest/index.js @@ -87,23 +87,21 @@ function sendData(params, callback) { const isMD = RegExp('^/markdown').test(p.name); if (isMD) - return markdown(p.name, p.request, (error, data) => { - callback(error, data); - }); + return markdown(p.name, p.request, callback); - switch(p.request.method) { + const method = p.request.method; + + switch(method) { case 'GET': - onGET(params, callback); - break; + return onGET(params, callback); case 'PUT': - pullout(p.request, 'string', (error, body) => { + return pullout(p.request, 'string', (error, body) => { if (error) return callback(error); onPUT(p.name, body, callback); }); - break; } }