http /api/status : Add array of known tables

This commit is contained in:
Starbeamrainbowlabs 2022-03-10 03:00:20 +00:00
parent 04479d5ce3
commit 2f7374a04b
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 15 additions and 1 deletions

View file

@ -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()
});
}

View file

@ -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)}`,