import type { PageServerLoad } from './$types'; import { getPostings, getUsers } from '$lib/db/index.server'; import { PERMISSIONS } from '$lib/consts'; import { error } from '@sveltejs/kit'; import { getUserPerms } from '$lib/index.server'; export const load: PageServerLoad = async ({ cookies, url }) => { const search = url.searchParams.get('searchPostings'); const perms = getUserPerms(cookies); if (perms >= 0 && (perms & PERMISSIONS.MANAGE_POSTINGS) > 0) { return { postings: await getPostings(search) }; } error(403, 'Unauthorized'); };