http /api/status : Add array of known tables
This commit is contained in:
parent
04479d5ce3
commit
2f7374a04b
2 changed files with 15 additions and 1 deletions
|
@ -4,6 +4,7 @@ export default async function(sys, ctx, _next) {
|
||||||
ctx.send.json(200, {
|
ctx.send.json(200, {
|
||||||
version: `${sys.version}-${sys.commit.substring(0, 7)}`,
|
version: `${sys.version}-${sys.commit.substring(0, 7)}`,
|
||||||
// TODO: Implement a fancier check here
|
// TODO: Implement a fancier check here
|
||||||
status: sys.listening ? "ok" : "not_listening"
|
status: sys.listening ? "ok" : "not_listening",
|
||||||
|
tables: sys.info.list_tables()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
is_valid_table(name) {
|
||||||
return Object.keys(this.allowed_tables).includes(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() {
|
async make_table_meta() {
|
||||||
return {
|
return {
|
||||||
version: `${this.sysquery.version}-${this.sysquery.commit.substring(0, 7)}`,
|
version: `${this.sysquery.version}-${this.sysquery.commit.substring(0, 7)}`,
|
||||||
|
|
Loading…
Reference in a new issue