Skip to content

Commit

Permalink
Merge pull request #110 from snyk/fix/all-clients-metadata
Browse files Browse the repository at this point in the history
fix: expose metadata of all clients on connection-status
  • Loading branch information
adrukh authored Mar 9, 2018
2 parents bc57db4 + bef919a commit a1c1e72
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ module.exports = ({ config = {}, port = null, filters = {} }) => {
const id = req.params.id;

if (connections.has(id)) {
const metadata = connections.get(id)[0].metadata;
return res.status(200).json({ ok: true, version: metadata.version });
const clientsMetadata = connections.get(id).map(conn => ({
version: conn.metadata && conn.metadata.version,
}));
return res.status(200).json({ ok: true, clients: clientsMetadata });
}
debug('no broker found matching "%s"', id);
return res.status(404).json({ ok: false });
Expand Down
4 changes: 2 additions & 2 deletions test/functional/healthcheck.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ test('proxy requests originating from behind the broker client', t => {

t.equal(res.statusCode, 200, '200 statusCode');
t.equal(res.body.ok, true, '{ ok: true } in body');
t.ok(res.body.version, 'version in body');
t.ok(res.body.clients[0].version, 'client version in body');
t.end();
});
});
Expand All @@ -97,7 +97,7 @@ test('proxy requests originating from behind the broker client', t => {

t.equal(res.statusCode, 200, '200 statusCode');
t.equal(res.body.ok, true, '{ ok: true } in body');
t.ok(res.body.version, 'version in body');
t.ok(res.body.clients[0].version, 'client version in body');
t.end();
});
}, 20);
Expand Down

0 comments on commit a1c1e72

Please sign in to comment.