add host route

This commit is contained in:
2023-04-20 11:36:02 +02:00
parent 01be7d8dd1
commit 96dcf2334b
3 changed files with 18 additions and 52 deletions
+9
View File
@@ -2,6 +2,7 @@ import { Router } from 'express'
import { param, query } from 'express-validator'
import { validateErrors } from '../common'
import { allData } from '../process/process'
import { getHostList } from '../db/db'
const router = Router()
//timeout middleware ?
@@ -20,6 +21,14 @@ function filters(e: any, query: any) {
)
}
router.get('/hosts',
async (req, res) => {
const result = (await getHostList())
const data: { [key: number]: string } = {}
result.forEach(e => data[Number(e.id)] = e.name)
res.status(200).send(data)
})
router.get(
'/:dataType',
param('dataType')