mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 14:54:33 +00:00
wrap use cache
This commit is contained in:
@@ -52,31 +52,33 @@ export const userService = createUserServiceClient(transport);
|
|||||||
export const oidcService = createOIDCServiceClient(transport);
|
export const oidcService = createOIDCServiceClient(transport);
|
||||||
export const idpService = createIdpServiceClient(transport);
|
export const idpService = createIdpServiceClient(transport);
|
||||||
export const orgService = createOrganizationServiceClient(transport);
|
export const orgService = createOrganizationServiceClient(transport);
|
||||||
|
|
||||||
export const settingsService = createSettingsServiceClient(transport);
|
export const settingsService = createSettingsServiceClient(transport);
|
||||||
|
|
||||||
export async function getBrandingSettings(organization?: string) {
|
async function cacheWrapper(callback: Promise<unknown>) {
|
||||||
if (process.env.DEBUG !== "true") {
|
"use cache";
|
||||||
// @ts-ignore
|
cacheLife("hours");
|
||||||
`${"use cache"}`;
|
|
||||||
cacheLife("hours");
|
|
||||||
}
|
|
||||||
|
|
||||||
return settingsService
|
return callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getBrandingSettings(organization?: string) {
|
||||||
|
const useCache = process.env.DEBUG !== "true";
|
||||||
|
|
||||||
|
const callback = settingsService
|
||||||
.getBrandingSettings({ ctx: makeReqCtx(organization) }, {})
|
.getBrandingSettings({ ctx: makeReqCtx(organization) }, {})
|
||||||
.then((resp) => (resp.settings ? resp.settings : undefined));
|
.then((resp) => (resp.settings ? resp.settings : undefined));
|
||||||
|
|
||||||
|
return useCache ? cacheWrapper(callback) : callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getLoginSettings(orgId?: string) {
|
export async function getLoginSettings(orgId?: string) {
|
||||||
if (process.env.DEBUG !== "true") {
|
const useCache = process.env.DEBUG !== "true";
|
||||||
// @ts-ignore
|
|
||||||
`${"use cache"}`;
|
|
||||||
cacheLife("hours");
|
|
||||||
}
|
|
||||||
|
|
||||||
return await settingsService
|
const callback = settingsService
|
||||||
.getLoginSettings({ ctx: makeReqCtx(orgId) }, {})
|
.getLoginSettings({ ctx: makeReqCtx(orgId) }, {})
|
||||||
.then((resp) => (resp.settings ? resp.settings : undefined));
|
.then((resp) => (resp.settings ? resp.settings : undefined));
|
||||||
|
|
||||||
|
return useCache ? cacheWrapper(callback) : callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function listIDPLinks(userId: string) {
|
export async function listIDPLinks(userId: string) {
|
||||||
@@ -106,39 +108,33 @@ export async function registerTOTP(userId: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getGeneralSettings() {
|
export async function getGeneralSettings() {
|
||||||
if (process.env.DEBUG !== "true") {
|
const useCache = process.env.DEBUG !== "true";
|
||||||
// @ts-ignore
|
|
||||||
`${"use cache"}`;
|
|
||||||
cacheLife("hours");
|
|
||||||
}
|
|
||||||
|
|
||||||
return settingsService
|
const callback = settingsService
|
||||||
.getGeneralSettings({}, {})
|
.getGeneralSettings({}, {})
|
||||||
.then((resp) => resp.supportedLanguages);
|
.then((resp) => resp.supportedLanguages);
|
||||||
|
|
||||||
|
return useCache ? cacheWrapper(callback) : callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getLegalAndSupportSettings(organization?: string) {
|
export async function getLegalAndSupportSettings(organization?: string) {
|
||||||
if (process.env.DEBUG !== "true") {
|
const useCache = process.env.DEBUG !== "true";
|
||||||
// @ts-ignore
|
|
||||||
`${"use cache"}`;
|
|
||||||
cacheLife("hours");
|
|
||||||
}
|
|
||||||
|
|
||||||
return settingsService
|
const callback = settingsService
|
||||||
.getLegalAndSupportSettings({ ctx: makeReqCtx(organization) }, {})
|
.getLegalAndSupportSettings({ ctx: makeReqCtx(organization) }, {})
|
||||||
.then((resp) => (resp.settings ? resp.settings : undefined));
|
.then((resp) => (resp.settings ? resp.settings : undefined));
|
||||||
|
|
||||||
|
return useCache ? cacheWrapper(callback) : callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getPasswordComplexitySettings(organization?: string) {
|
export async function getPasswordComplexitySettings(organization?: string) {
|
||||||
if (process.env.DEBUG !== "true") {
|
const useCache = process.env.DEBUG !== "true";
|
||||||
// @ts-ignore
|
|
||||||
`${"use cache"}`;
|
|
||||||
cacheLife("hours");
|
|
||||||
}
|
|
||||||
|
|
||||||
return settingsService
|
const callback = settingsService
|
||||||
.getPasswordComplexitySettings({ ctx: makeReqCtx(organization) })
|
.getPasswordComplexitySettings({ ctx: makeReqCtx(organization) })
|
||||||
.then((resp) => (resp.settings ? resp.settings : undefined));
|
.then((resp) => (resp.settings ? resp.settings : undefined));
|
||||||
|
|
||||||
|
return useCache ? cacheWrapper(callback) : callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createSessionFromChecks(
|
export async function createSessionFromChecks(
|
||||||
|
|||||||
Reference in New Issue
Block a user