import { auth } from "@pkg/logic/domains/auth/config.base";
import { redirect } from "@sveltejs/kit";
import type { LayoutServerLoad } from "./$types";

export const load = (async ({ request }) => {
	const sess = await auth.api.getSession({
		headers: request.headers,
	});
	if (!sess || !sess.user || !sess.session) {
		return redirect(302, "/auth/login");
	}
	// sess.session.id =
	return { user: sess.user as any, session: sess.session as any };
}) satisfies LayoutServerLoad;
