Merge pull request #13906 from Budibase/fix/status-with-version

Adding version to system status call
This commit is contained in:
Michael Drury 2024-06-10 19:09:56 +01:00 committed by GitHub
commit 7d28dbd4c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 28 additions and 7 deletions

View File

@ -1 +1,2 @@
export * from "./environment" export * from "./environment"
export * from "./status"

View File

@ -0,0 +1,11 @@
export type SystemStatusResponse = {
passing?: boolean
checks?: {
login: boolean
search: boolean
}
health?: {
passing: boolean
}
version?: string
}

View File

@ -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 env from "../../../environment"
import { BBContext } from "@budibase/types"
export const fetch = async (ctx: BBContext) => { export const fetch = async (ctx: Ctx<void, SystemStatusResponse>) => {
let status: SystemStatusResponse | undefined
if (!env.SELF_HOSTED && !env.DISABLE_ACCOUNT_PORTAL) { if (!env.SELF_HOSTED && !env.DISABLE_ACCOUNT_PORTAL) {
const status = await accounts.getStatus() status = await accounts.getStatus()
ctx.body = status }
} else {
ctx.body = { if (!status) {
status = {
health: { health: {
passing: true, passing: true,
}, },
} }
} }
if (coreEnv.VERSION) {
status.version = coreEnv.VERSION
}
ctx.body = status
} }

View File

@ -27,6 +27,7 @@ describe("/api/system/status", () => {
health: { health: {
passing: true, passing: true,
}, },
version: expect.any(String),
}) })
expect(accounts.getStatus).toHaveBeenCalledTimes(0) expect(accounts.getStatus).toHaveBeenCalledTimes(0)
config.cloudHosted() config.cloudHosted()