From 2f7374a04b1270a7fb10c374b0ee0f8de63ee5c5 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Thu, 10 Mar 2022 03:00:20 +0000 Subject: [PATCH] http /api/status : Add array of known tables --- src/lib/agent/subsystems/http/routes/status.mjs | 3 ++- src/lib/core/InfoBroker.mjs | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/lib/agent/subsystems/http/routes/status.mjs b/src/lib/agent/subsystems/http/routes/status.mjs index 55c0b42..0f9ed25 100644 --- a/src/lib/agent/subsystems/http/routes/status.mjs +++ b/src/lib/agent/subsystems/http/routes/status.mjs @@ -4,6 +4,7 @@ export default async function(sys, ctx, _next) { ctx.send.json(200, { version: `${sys.version}-${sys.commit.substring(0, 7)}`, // TODO: Implement a fancier check here - status: sys.listening ? "ok" : "not_listening" + status: sys.listening ? "ok" : "not_listening", + tables: sys.info.list_tables() }); } diff --git a/src/lib/core/InfoBroker.mjs b/src/lib/core/InfoBroker.mjs index 27a0030..e56098e 100644 --- a/src/lib/core/InfoBroker.mjs +++ b/src/lib/core/InfoBroker.mjs @@ -28,10 +28,23 @@ class InfoBroker { }; } + /** + * Determines if the given table name is valid or not. + * @param {string} name The table name to validate. + * @return {Boolean} Whether the table name is valid (true) or not (false). + */ is_valid_table(name) { return Object.keys(this.allowed_tables).includes(name); } + /** + * Returns a list of known table names. + * @return {string[]} A list of known table names. + */ + list_tables() { + return Object.keys(this.allowed_tables); + } + async make_table_meta() { return { version: `${this.sysquery.version}-${this.sysquery.commit.substring(0, 7)}`,