Add counts to the serverList output
This commit is contained in:
parent
44a52d2ba8
commit
7922796b7d
12
index.js
12
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
|
// checkServer function
|
||||||
function checkServer(address) {
|
function checkServer(address) {
|
||||||
Steam.queryGameServerInfo(address).then(data => {
|
Steam.queryGameServerInfo(address).then(data => {
|
||||||
|
@ -198,6 +208,8 @@ app.get('/check', (req, res) => {
|
||||||
// });
|
// });
|
||||||
|
|
||||||
app.get('/serverList', (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));
|
res.setHeader("Content-Type", "application/json").send(JSON.stringify(serverList));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue