remover unnecessary return
routes/api.js - dispatchcommand refactored
This commit is contained in:
+5
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user