Browse Source

Updating cache to 1 hour.

master
mike12345567 4 years ago
parent
commit
7be0dad245
  1. 2
      packages/backend-core/src/cache/generic.js
  2. 102
      packages/worker/src/api/controllers/global/configs.js

2
packages/backend-core/src/cache/generic.js

@ -8,6 +8,8 @@ exports.CacheKeys = {
exports.TTL = { exports.TTL = {
ONE_MINUTE: 600, ONE_MINUTE: 600,
ONE_HOUR: 3600,
ONE_DAY: 86400,
} }
function generateTenantKey(key) { function generateTenantKey(key) {

102
packages/worker/src/api/controllers/global/configs.js

@ -256,62 +256,58 @@ exports.configChecklist = async function (ctx) {
const tenantId = getTenantId() const tenantId = getTenantId()
try { try {
ctx.body = await withCache( ctx.body = await withCache(CacheKeys.CHECKLIST, TTL.ONE_HOUR, async () => {
CacheKeys.CHECKLIST, let apps = []
TTL.ONE_MINUTE, if (!env.MULTI_TENANCY || tenantId) {
async () => { // Apps exist
let apps = [] apps = await getAllApps({ idsOnly: true, efficient: true })
if (!env.MULTI_TENANCY || tenantId) { }
// Apps exist
apps = await getAllApps({ idsOnly: true, efficient: true })
}
// They have set up SMTP
const smtpConfig = await getScopedFullConfig(db, {
type: Configs.SMTP,
})
// They have set up Google Auth
const googleConfig = await getScopedFullConfig(db, {
type: Configs.GOOGLE,
})
// They have set up OIDC // They have set up SMTP
const oidcConfig = await getScopedFullConfig(db, { const smtpConfig = await getScopedFullConfig(db, {
type: Configs.OIDC, 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,
}) })
)
// They have set up an global user return {
const users = await db.allDocs( apps: {
getGlobalUserParams(null, { checked: apps.length > 0,
include_docs: true, label: "Create your first app",
limit: 1, link: "/builder/portal/apps",
}) },
) smtp: {
return { checked: !!smtpConfig,
apps: { label: "Set up email",
checked: apps.length > 0, link: "/builder/portal/manage/email",
label: "Create your first app", },
link: "/builder/portal/apps", adminUser: {
}, checked: users && users.rows.length >= 1,
smtp: { label: "Create your first user",
checked: !!smtpConfig, link: "/builder/portal/manage/users",
label: "Set up email", },
link: "/builder/portal/manage/email", sso: {
}, checked: !!googleConfig || !!oidcConfig,
adminUser: { label: "Set up single sign-on",
checked: users && users.rows.length >= 1, link: "/builder/portal/manage/auth",
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)
} }

Loading…
Cancel
Save