routes: add /api/status

This commit is contained in:
Starbeamrainbowlabs 2022-02-24 01:28:03 +00:00
parent 19ea1ff428
commit ecdd52561a
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 11 additions and 0 deletions

View file

@ -6,6 +6,7 @@ import middleware_log from './routes/middleware_log.mjs';
import middleware_catch_errors from './routes/middleware_errors.mjs';
import route_table from './routes/table.mjs';
import route_static from './routes/static.mjs';
import route_status from './routes/status.mjs';
export default function(sys) {
const router = new ServerRouter();
@ -17,6 +18,7 @@ export default function(sys) {
///
// API
///
router.get(`/api/status`, route_status.bind(this, sys));
router.get(`/api/table/:table_name`, route_table.bind(this, sys));
///

View file

@ -0,0 +1,9 @@
"use strict";
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"
});
}