routes: add /api/status
This commit is contained in:
parent
19ea1ff428
commit
ecdd52561a
2 changed files with 11 additions and 0 deletions
|
@ -6,6 +6,7 @@ import middleware_log from './routes/middleware_log.mjs';
|
||||||
import middleware_catch_errors from './routes/middleware_errors.mjs';
|
import middleware_catch_errors from './routes/middleware_errors.mjs';
|
||||||
import route_table from './routes/table.mjs';
|
import route_table from './routes/table.mjs';
|
||||||
import route_static from './routes/static.mjs';
|
import route_static from './routes/static.mjs';
|
||||||
|
import route_status from './routes/status.mjs';
|
||||||
|
|
||||||
export default function(sys) {
|
export default function(sys) {
|
||||||
const router = new ServerRouter();
|
const router = new ServerRouter();
|
||||||
|
@ -17,6 +18,7 @@ export default function(sys) {
|
||||||
///
|
///
|
||||||
// API
|
// API
|
||||||
///
|
///
|
||||||
|
router.get(`/api/status`, route_status.bind(this, sys));
|
||||||
router.get(`/api/table/:table_name`, route_table.bind(this, sys));
|
router.get(`/api/table/:table_name`, route_table.bind(this, sys));
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
9
src/lib/agent/subsystems/http/routes/status.mjs
Normal file
9
src/lib/agent/subsystems/http/routes/status.mjs
Normal 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"
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in a new issue