import type { PageServerLoad } from './$types.js'; import { withTenant } from '$lib/server/rls.js'; export const load: PageServerLoad = async ({ locals }) => { const tenant = locals.tenant; if (!tenant) return { boards: [] }; const boards = await withTenant(tenant.id, async (tx) => { const where: any = { tenantId: tenant.id, archived: false }; if (!locals.user) { where.visibility = 'PUBLIC'; } else { where.OR = [ { visibility: 'PUBLIC' }, { members: { some: { userId: locals.user.id } } } ]; } return tx.board.findMany({ where, include: { members: { include: { user: { select: { id: true, name: true, avatarUrl: true } } } }, _count: { select: { columns: true } } }, orderBy: { updatedAt: 'desc' } }); }); return { boards }; };