mirror of
https://github.com/nikdoof/pocket-id.git
synced 2025-12-24 14:59:23 +00:00
25 lines
767 B
TypeScript
25 lines
767 B
TypeScript
import AppConfigService from '$lib/services/app-config-service';
|
|
import type { AppVersionInformation } from '$lib/types/application-configuration';
|
|
import type { LayoutServerLoad } from './$types';
|
|
|
|
let versionInformation: AppVersionInformation;
|
|
let versionInformationLastUpdated: number;
|
|
|
|
export const load: LayoutServerLoad = async () => {
|
|
const appConfigService = new AppConfigService();
|
|
|
|
// Cache the version information for 3 hours
|
|
const cacheExpired =
|
|
versionInformationLastUpdated &&
|
|
Date.now() - versionInformationLastUpdated > 1000 * 60 * 60 * 3;
|
|
|
|
if (!versionInformation || cacheExpired) {
|
|
versionInformation = await appConfigService.getVersionInformation();
|
|
versionInformationLastUpdated = Date.now();
|
|
}
|
|
|
|
return {
|
|
versionInformation
|
|
};
|
|
};
|