2024-09-09 10:29:41 +02:00
|
|
|
import AppConfigService from '$lib/services/app-config-service';
|
2024-08-12 11:00:25 +02:00
|
|
|
import UserService from '$lib/services/user-service';
|
|
|
|
|
import type { LayoutServerLoad } from './$types';
|
|
|
|
|
|
|
|
|
|
export const load: LayoutServerLoad = async ({ cookies }) => {
|
|
|
|
|
const userService = new UserService(cookies.get('access_token'));
|
2024-09-09 10:29:41 +02:00
|
|
|
const appConfigService = new AppConfigService(cookies.get('access_token'));
|
2024-08-12 11:00:25 +02:00
|
|
|
|
|
|
|
|
const user = await userService
|
|
|
|
|
.getCurrent()
|
|
|
|
|
.then((user) => user)
|
|
|
|
|
.catch(() => null);
|
|
|
|
|
|
2024-09-09 10:29:41 +02:00
|
|
|
const appConfig = await appConfigService
|
2024-08-12 11:00:25 +02:00
|
|
|
.list()
|
|
|
|
|
.then((config) => config)
|
|
|
|
|
.catch((e) => {
|
|
|
|
|
console.error(
|
|
|
|
|
`Failed to get application configuration: ${e.response?.data.error || e.message}`
|
|
|
|
|
);
|
|
|
|
|
return null;
|
|
|
|
|
});
|
|
|
|
|
return {
|
|
|
|
|
user,
|
2024-09-09 10:29:41 +02:00
|
|
|
appConfig
|
2024-08-12 11:00:25 +02:00
|
|
|
};
|
|
|
|
|
};
|