From edeb871c2b2efa09313604d14fa41981391557ad Mon Sep 17 00:00:00 2001 From: rxf Date: Thu, 1 Jun 2023 15:57:06 +0200 Subject: [PATCH] remover unnecessary return routes/api.js - dispatchcommand refactored --- routes/api.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/routes/api.js b/routes/api.js index 8512d20..995b388 100644 --- a/routes/api.js +++ b/routes/api.js @@ -26,8 +26,10 @@ export const translate = (x) => { } export const dispatchCommand = async (cmd, table, params, res) => { + let notfound = true for (let c of table) { if (c.cmd === cmd) { + notfound = false let erg = await c.func(params) if (typeof erg === 'string') { res.type('text') @@ -35,10 +37,11 @@ export const dispatchCommand = async (cmd, table, params, res) => { } else { res.json(erg) } - return } } - res.json({err:translate('CMNDUNKNOWN')}) + if (notfound) { + res.json({err: translate('CMNDUNKNOWN')}) + } } // normal routes called from javascript client