Viele Updates, Version angepasst

This commit is contained in:
2023-11-12 11:26:15 +00:00
parent 5dc66dbaa2
commit a79f6add1a
14 changed files with 127 additions and 25 deletions
+11 -5
View File
@@ -21,12 +21,13 @@ let APIHOST = process.env.APIHOST || 'http://localhost:3005'
/* GET home page. */
router.get('/:cmd', async function(req, res, next) {
// req.i18n.changeLanguage(req.query.lng)
const calledAs = req.baseUrl
const cmd = req.params.cmd
const pretty = (req.query.pretty !== undefined)
const lng = getLanguage()
let url = APIHOST
url += (req.originalUrl + `&lng=${lng}`)
let url = APIHOST + '/api' + req.originalUrl.slice(4) + `&lng=${lng}`
try {
const response = await axios(encodeURI(url));
const response = await axios.get(encodeURI(url));
if (response.status !== 200) {
res.json({err: `${trans('ESYSCALL')} status=${response.status}`})
}
@@ -34,9 +35,14 @@ router.get('/:cmd', async function(req, res, next) {
res.json(response.data)
return
}
if ((cmd === 'getoneproperty') || (cmd === 'getaddress')) {
// if called as '/api' then directly return the data
if ((calledAs === '/api') || (cmd === 'getoneproperty') || (cmd === 'getaddress')) {
if(pretty) {
res.send(JSON.stringify(response.data,null,2))
} else {
res.json(response.data)
return
}
return
}
const options = response.data.options
for(let x of disttable) {