Add status endpoint to API
This commit is contained in:
15
src/index.js
15
src/index.js
@@ -33,6 +33,19 @@ app.get('/', (req, res) => {
|
|||||||
|
|
||||||
app.use('/example', express.static(path.join(__dirname, 'example')));
|
app.use('/example', express.static(path.join(__dirname, 'example')));
|
||||||
|
|
||||||
|
app.get('/status', (req, res) => {
|
||||||
|
let queued = Object.values(jobs['queued']);
|
||||||
|
|
||||||
|
res.json(
|
||||||
|
{
|
||||||
|
'nodes': Array.from(wss.clients),
|
||||||
|
'jobs': {
|
||||||
|
'queued': { 'count': queued.length, 'items': queued },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
app.get('/jobs', (req, res) => {
|
app.get('/jobs', (req, res) => {
|
||||||
let queued = Object.values(jobs['queued']);
|
let queued = Object.values(jobs['queued']);
|
||||||
|
|
||||||
@@ -147,4 +160,4 @@ app.use('/public', express.static('public'));
|
|||||||
|
|
||||||
app.listen(PORT_WEB, () => {
|
app.listen(PORT_WEB, () => {
|
||||||
console.log(`Job Server API running on ${PORT_WEB}`);
|
console.log(`Job Server API running on ${PORT_WEB}`);
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user