Add counts to the serverList output
This commit is contained in:
parent
44a52d2ba8
commit
7922796b7d
14
index.js
14
index.js
|
@ -59,6 +59,16 @@ function checkVersion(version) {
|
|||
}
|
||||
};
|
||||
|
||||
function objectLength(object) {
|
||||
var length = 0;
|
||||
for (var key in object) {
|
||||
if (object.hasOwnProperty(key)) {
|
||||
++length;
|
||||
}
|
||||
}
|
||||
return length;
|
||||
};
|
||||
|
||||
// checkServer function
|
||||
function checkServer(address) {
|
||||
Steam.queryGameServerInfo(address).then(data => {
|
||||
|
@ -198,6 +208,8 @@ app.get('/check', (req, res) => {
|
|||
// });
|
||||
|
||||
app.get('/serverList', (req, res) => {
|
||||
serverList.serverCount = objectLength(serverList.servers);
|
||||
serverList.erroredCount = objectLength(serverList.errored);
|
||||
res.setHeader("Content-Type", "application/json").send(JSON.stringify(serverList));
|
||||
});
|
||||
|
||||
|
@ -212,4 +224,4 @@ app.get('/', (req, res) => {
|
|||
});
|
||||
|
||||
|
||||
app.listen(port, () => console.log(`Listening on port ${port}!`));
|
||||
app.listen(port, () => console.log(`Listening on port ${port}!`));
|
Loading…
Reference in a new issue