1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-03-27 02:12:34 +01:00
immich/web/src/routes/(user)/albums/+page.server.ts
Michel Heusschen 807bdfeda9
fix(web): layout nesting ()
Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
2023-02-26 21:23:43 -06:00

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;