feat: add backend status check handler middleware

The statusCheckHandler is a simple express middleware that helps
implement healthcheck/readiness endpoints. It can provided an optional
status function that should return a promise that resolves in either
true or false. The response will be either a 200 or 503 respectively.
Any errors that occur will be forwarded to next.
This commit is contained in:
Andrew Thauer
2020-07-11 15:38:16 -04:00
parent 3158c2390b
commit 88e3581ebc
6 changed files with 114 additions and 5 deletions
+2
View File
@@ -25,6 +25,7 @@
import {
createServiceBuilder,
getRootLogger,
statusCheckHandler,
useHotMemoize,
} from '@backstage/backend-common';
import { ConfigReader, AppConfig } from '@backstage/config';
@@ -73,6 +74,7 @@ async function main() {
const service = createServiceBuilder(module)
.loadConfig(configReader)
.addRouter('/healthcheck', await statusCheckHandler())
.addRouter('/catalog', await catalog(catalogEnv))
.addRouter('/rollbar', await rollbar(rollbarEnv))
.addRouter('/scaffolder', await scaffolder(scaffolderEnv))