mirror of
https://github.com/immich-app/immich.git
synced 2025-03-27 02:12:34 +01:00
24 lines
491 B
TypeScript
24 lines
491 B
TypeScript
import { redirect } from '@sveltejs/kit';
|
|
import type { PageServerLoad } from './$types';
|
|
|
|
export const load = (async ({ parent, locals: { api } }) => {
|
|
try {
|
|
const { user } = await parent();
|
|
|
|
if (!user) {
|
|
throw Error('User is not logged in');
|
|
}
|
|
|
|
const { data: albums } = await api.albumApi.getAllAlbums();
|
|
|
|
return {
|
|
user: user,
|
|
albums: albums,
|
|
meta: {
|
|
title: 'Albums'
|
|
}
|
|
};
|
|
} catch (e) {
|
|
throw redirect(302, '/auth/login');
|
|
}
|
|
}) satisfies PageServerLoad;
|