From 3a95aa6aeb1b9b5e28401981206737ee49aeab4b Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 10 Jun 2024 18:56:24 +0100 Subject: [PATCH 1/2] Adding the version to the status to help understand what version the service is using. --- packages/types/src/api/web/system/index.ts | 1 + packages/types/src/api/web/system/status.ts | 11 ++++++++++ .../src/api/controllers/system/status.ts | 22 +++++++++++++------ 3 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 packages/types/src/api/web/system/status.ts diff --git a/packages/types/src/api/web/system/index.ts b/packages/types/src/api/web/system/index.ts index d19c9296c9..8820bf5cd1 100644 --- a/packages/types/src/api/web/system/index.ts +++ b/packages/types/src/api/web/system/index.ts @@ -1 +1,2 @@ export * from "./environment" +export * from "./status" diff --git a/packages/types/src/api/web/system/status.ts b/packages/types/src/api/web/system/status.ts new file mode 100644 index 0000000000..3d64cc4d97 --- /dev/null +++ b/packages/types/src/api/web/system/status.ts @@ -0,0 +1,11 @@ +export type SystemStatusResponse = { + passing?: boolean + checks?: { + login: boolean + search: boolean + } + health?: { + passing: boolean + } + version?: string +} diff --git a/packages/worker/src/api/controllers/system/status.ts b/packages/worker/src/api/controllers/system/status.ts index b763a67d4f..662ca05c48 100644 --- a/packages/worker/src/api/controllers/system/status.ts +++ b/packages/worker/src/api/controllers/system/status.ts @@ -1,16 +1,24 @@ -import { accounts } from "@budibase/backend-core" +import { accounts, env as coreEnv } from "@budibase/backend-core" +import { Ctx, SystemStatusResponse } from "@budibase/types" import env from "../../../environment" -import { BBContext } from "@budibase/types" -export const fetch = async (ctx: BBContext) => { +export const fetch = async (ctx: Ctx) => { + let status: SystemStatusResponse | undefined if (!env.SELF_HOSTED && !env.DISABLE_ACCOUNT_PORTAL) { - const status = await accounts.getStatus() - ctx.body = status - } else { - ctx.body = { + status = await accounts.getStatus() + } + + if (!status) { + status = { health: { passing: true, }, } } + + if (coreEnv.VERSION) { + status.version = coreEnv.VERSION + } + + ctx.body = status } From d4d3537f41e198069d2bba56579643ec2f297160 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 10 Jun 2024 19:02:30 +0100 Subject: [PATCH 2/2] Updating test. --- packages/worker/src/api/routes/system/tests/status.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/worker/src/api/routes/system/tests/status.spec.ts b/packages/worker/src/api/routes/system/tests/status.spec.ts index 71e01a0e72..cfb9e2d68f 100644 --- a/packages/worker/src/api/routes/system/tests/status.spec.ts +++ b/packages/worker/src/api/routes/system/tests/status.spec.ts @@ -27,6 +27,7 @@ describe("/api/system/status", () => { health: { passing: true, }, + version: expect.any(String), }) expect(accounts.getStatus).toHaveBeenCalledTimes(0) config.cloudHosted()