Add route to get list of jobs
This commit is contained in:
15
index.js
15
index.js
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user