Add route to get list of jobs

This commit is contained in:
2023-01-10 23:00:10 +01:00
parent 860fabe2af
commit 65d4f412b3

View File

@@ -18,6 +18,21 @@ app.get('/', (req, res) => {
res.send('Job handling server')
})
app.get('/jobs', (req, res) => {
let queued = Object.values(jobs['queued']);
let waiting = Object.values(jobs['waiting']);
let finished = Object.values(jobs['finished']);
res.json(
{
'jobs': {
'queued': { 'count': queued.length, 'items': queued },
'waiting': { 'count': waiting.length, 'items': waiting },
'finished': { 'count': finished.length, 'items': finished },
}
}
);
});
app.listen(PORT, () => {
console.log("Job Server running")