Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
IchthysMaranathaCopy authored Mar 13, 2024
1 parent 6da2704 commit 5ce9bb7
Showing 1 changed file with 4 additions and 31 deletions.
35 changes: 4 additions & 31 deletions packages/worker/src/api/controllers/system/environment.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,14 @@
import { Ctx } from "@budibase/types"
import { BBContext } from "@budibase/types"
import env from "../../../environment"
import { env as coreEnv } from "@budibase/backend-core"
import nodeFetch from "node-fetch"

let sqsAvailable: boolean
async function isSqsAvailable() {
if (sqsAvailable !== undefined) {
return sqsAvailable
}

try {
await nodeFetch(coreEnv.COUCH_DB_SQL_URL, {
timeout: 1000,
})
sqsAvailable = true
return true
} catch (e) {
sqsAvailable = false
return false
}
}

export const fetch = async (ctx: Ctx) => {
export const fetch = async (ctx: BBContext) => {
ctx.body = {
multiTenancy: !!env.MULTI_TENANCY,
offlineMode: !!coreEnv.OFFLINE_MODE,
cloud: !env.SELF_HOSTED,
accountPortalUrl: env.ACCOUNT_PORTAL_URL,
disableAccountPortal: env.DISABLE_ACCOUNT_PORTAL,
baseUrl: env.PLATFORM_URL,
isDev: env.isDev() && !env.isTest(),
directoidc: env.DIRECT_OIDC,
}

if (env.SELF_HOSTED) {
ctx.body.infrastructure = {
sqs: await isSqsAvailable(),
}
// in test need to pretend its in production for the UI (Cypress)
isDev: env.isDev() && !env.isTest(),
}
}

0 comments on commit 5ce9bb7

Please sign in to comment.