1
0
Fork 0
mirror of synced 2024-06-30 20:10:54 +12:00

Add isSqsAvailable key to the environment endpoint.

This commit is contained in:
Sam Rose 2023-12-11 15:22:02 +00:00
parent 31381111b0
commit 6b491815a5
No known key found for this signature in database
2 changed files with 21 additions and 0 deletions

View file

@ -107,6 +107,7 @@ const environment = {
ENCRYPTION_KEY: process.env.ENCRYPTION_KEY,
API_ENCRYPTION_KEY: getAPIEncryptionKey(),
COUCH_DB_URL: process.env.COUCH_DB_URL || "http://localhost:4005",
COUCH_DB_SQL_URL: process.env.COUCH_DB_SQL_URL || "http://localhost:4984",
COUCH_DB_USERNAME: process.env.COUCH_DB_USER,
COUCH_DB_PASSWORD: process.env.COUCH_DB_PASSWORD,
GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID,

View file

@ -1,6 +1,25 @@
import { Ctx } 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,
})
} catch (e) {
sqsAvailable = false
return false
}
sqsAvailable = true
return true
}
export const fetch = async (ctx: Ctx) => {
ctx.body = {
@ -11,5 +30,6 @@ export const fetch = async (ctx: Ctx) => {
disableAccountPortal: env.DISABLE_ACCOUNT_PORTAL,
baseUrl: env.PLATFORM_URL,
isDev: env.isDev() && !env.isTest(),
isSqsAvailable: await isSqsAvailable(),
}
}