making checklist cache length controllable through env var
This commit is contained in:
parent
518797295e
commit
e1bacb7cca
|
@ -17,7 +17,6 @@ const { googleCallbackUrl, oidcCallbackUrl } = require("./auth")
|
||||||
const {
|
const {
|
||||||
withCache,
|
withCache,
|
||||||
CacheKeys,
|
CacheKeys,
|
||||||
TTL,
|
|
||||||
bustCache,
|
bustCache,
|
||||||
} = require("@budibase/backend-core/cache")
|
} = require("@budibase/backend-core/cache")
|
||||||
|
|
||||||
|
@ -256,58 +255,62 @@ exports.configChecklist = async function (ctx) {
|
||||||
const tenantId = getTenantId()
|
const tenantId = getTenantId()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ctx.body = await withCache(CacheKeys.CHECKLIST, TTL.ONE_HOUR, async () => {
|
ctx.body = await withCache(
|
||||||
let apps = []
|
CacheKeys.CHECKLIST,
|
||||||
if (!env.MULTI_TENANCY || tenantId) {
|
env.CHECKLIST_CACHE_TTL,
|
||||||
// Apps exist
|
async () => {
|
||||||
apps = await getAllApps({ idsOnly: true, efficient: true })
|
let apps = []
|
||||||
}
|
if (!env.MULTI_TENANCY || tenantId) {
|
||||||
|
// Apps exist
|
||||||
|
apps = await getAllApps({ idsOnly: true, efficient: true })
|
||||||
|
}
|
||||||
|
|
||||||
// They have set up SMTP
|
// They have set up SMTP
|
||||||
const smtpConfig = await getScopedFullConfig(db, {
|
const smtpConfig = await getScopedFullConfig(db, {
|
||||||
type: Configs.SMTP,
|
type: Configs.SMTP,
|
||||||
})
|
|
||||||
|
|
||||||
// They have set up Google Auth
|
|
||||||
const googleConfig = await getScopedFullConfig(db, {
|
|
||||||
type: Configs.GOOGLE,
|
|
||||||
})
|
|
||||||
|
|
||||||
// They have set up OIDC
|
|
||||||
const oidcConfig = await getScopedFullConfig(db, {
|
|
||||||
type: Configs.OIDC,
|
|
||||||
})
|
|
||||||
|
|
||||||
// They have set up an global user
|
|
||||||
const users = await db.allDocs(
|
|
||||||
getGlobalUserParams(null, {
|
|
||||||
include_docs: true,
|
|
||||||
limit: 1,
|
|
||||||
})
|
})
|
||||||
)
|
|
||||||
return {
|
// They have set up Google Auth
|
||||||
apps: {
|
const googleConfig = await getScopedFullConfig(db, {
|
||||||
checked: apps.length > 0,
|
type: Configs.GOOGLE,
|
||||||
label: "Create your first app",
|
})
|
||||||
link: "/builder/portal/apps",
|
|
||||||
},
|
// They have set up OIDC
|
||||||
smtp: {
|
const oidcConfig = await getScopedFullConfig(db, {
|
||||||
checked: !!smtpConfig,
|
type: Configs.OIDC,
|
||||||
label: "Set up email",
|
})
|
||||||
link: "/builder/portal/manage/email",
|
|
||||||
},
|
// They have set up an global user
|
||||||
adminUser: {
|
const users = await db.allDocs(
|
||||||
checked: users && users.rows.length >= 1,
|
getGlobalUserParams(null, {
|
||||||
label: "Create your first user",
|
include_docs: true,
|
||||||
link: "/builder/portal/manage/users",
|
limit: 1,
|
||||||
},
|
})
|
||||||
sso: {
|
)
|
||||||
checked: !!googleConfig || !!oidcConfig,
|
return {
|
||||||
label: "Set up single sign-on",
|
apps: {
|
||||||
link: "/builder/portal/manage/auth",
|
checked: apps.length > 0,
|
||||||
},
|
label: "Create your first app",
|
||||||
|
link: "/builder/portal/apps",
|
||||||
|
},
|
||||||
|
smtp: {
|
||||||
|
checked: !!smtpConfig,
|
||||||
|
label: "Set up email",
|
||||||
|
link: "/builder/portal/manage/email",
|
||||||
|
},
|
||||||
|
adminUser: {
|
||||||
|
checked: users && users.rows.length >= 1,
|
||||||
|
label: "Create your first user",
|
||||||
|
link: "/builder/portal/manage/users",
|
||||||
|
},
|
||||||
|
sso: {
|
||||||
|
checked: !!googleConfig || !!oidcConfig,
|
||||||
|
label: "Set up single sign-on",
|
||||||
|
link: "/builder/portal/manage/auth",
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
ctx.throw(err.status, err)
|
ctx.throw(err.status, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const { join } = require("path")
|
const { join } = require("path")
|
||||||
|
const { TTL } = require("@budibase/backend-core/cache")
|
||||||
|
|
||||||
function isDev() {
|
function isDev() {
|
||||||
return process.env.NODE_ENV !== "production"
|
return process.env.NODE_ENV !== "production"
|
||||||
|
@ -52,7 +53,8 @@ module.exports = {
|
||||||
SMTP_FROM_ADDRESS: process.env.SMTP_FROM_ADDRESS,
|
SMTP_FROM_ADDRESS: process.env.SMTP_FROM_ADDRESS,
|
||||||
PLATFORM_URL: process.env.PLATFORM_URL,
|
PLATFORM_URL: process.env.PLATFORM_URL,
|
||||||
COOKIE_DOMAIN: process.env.COOKIE_DOMAIN,
|
COOKIE_DOMAIN: process.env.COOKIE_DOMAIN,
|
||||||
CHECKLIST_CACHE_TTL: parseIntSafe(process.env.CHECKLIST_CACHE_TTL) || 600,
|
CHECKLIST_CACHE_TTL:
|
||||||
|
parseIntSafe(process.env.CHECKLIST_CACHE_TTL) || TTL.ONE_HOUR,
|
||||||
APPS_URL: process.env.APPS_URL,
|
APPS_URL: process.env.APPS_URL,
|
||||||
_set(key, value) {
|
_set(key, value) {
|
||||||
process.env[key] = value
|
process.env[key] = value
|
||||||
|
|
Loading…
Reference in New Issue