import type { LayoutServerLoad } from './$types';
import { Admin, User } from '$lib/server/database';
import { getSession } from '$lib/server/session';

export const load: LayoutServerLoad = async ({ cookies }) => {
	const session = getSession(cookies);

	return {
		userCount: session?.permissions.userRead() ? await User.count() : null,
		adminCount: session?.permissions.adminRead() ? await Admin.count() : null
	};
};
