All error messages in german and in englisch
This commit is contained in:
+7
-5
@@ -1,16 +1,12 @@
|
||||
import express from 'express'
|
||||
|
||||
import {getData4map} from "../actions/data4map.js"
|
||||
import * as ERR from "../utilities/errortexts.js"
|
||||
import * as getData from "../actions/getsensorData.js";
|
||||
import * as getProps from "../actions/getproperties.js";
|
||||
import * as getAKWs from "../actions/getAKWData.js";
|
||||
import * as holAddr from "../actions/getaddress.js";
|
||||
|
||||
export const apiRouter = express.Router();
|
||||
import { logit, logerror } from '../utilities/logit.js'
|
||||
|
||||
|
||||
|
||||
const cmdTable = [
|
||||
{cmd: 'getactdata', func: getData.getActData},
|
||||
@@ -23,6 +19,11 @@ const cmdTable = [
|
||||
{cmd: 'getmapdata', func: getData4map}
|
||||
]
|
||||
|
||||
let i18n;
|
||||
|
||||
export const translate = (x) => {
|
||||
return i18n.t(x)
|
||||
}
|
||||
|
||||
export const dispatchCommand = async (cmd, table, params, res) => {
|
||||
for (let c of table) {
|
||||
@@ -37,12 +38,13 @@ export const dispatchCommand = async (cmd, table, params, res) => {
|
||||
return
|
||||
}
|
||||
}
|
||||
res.json({err: ERR.CMNDUNKOWN})
|
||||
res.json({err:translate('CMNDUNKNOWN')})
|
||||
}
|
||||
|
||||
// normal routes called from javascript client
|
||||
apiRouter.get('/:cmd', async (req, res) => {
|
||||
const params = req.query
|
||||
params.chart = false
|
||||
i18n = req.i18n
|
||||
await dispatchCommand(req.params.cmd, cmdTable, params, res)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user