add users endpoint

This commit is contained in:
Sam Calder-Mason 2020-03-27 21:56:00 +11:00
parent cf0c8966ee
commit 454f36c844
1 changed files with 5 additions and 0 deletions

View File

@ -38,6 +38,11 @@ ptserver.get('/health', (req, res) => {
}
return res.send(JSON.stringify({ load })).end();
});
ptserver.get('/users', (req, res) => {
res.setHeader('Content-Type', 'application/json');
const users = Object.keys(ptserver_io.sockets.connected).length;
return res.send(JSON.stringify({ users })).end();
});
ptserver.get('/', (req, res) => res.send('You\'ve connected to the SLServer, you\'re probably looking for the webapp.'));
// Merge everything together