--- export const prerender = false; import { getSession } from 'auth-astro/server'; import { getPendingEntries, type GuestbookEntry } from '../lib/db'; import { isAdmin } from '../lib/auth'; import Layout from '../layouts/Layout.astro'; let session; try { session = await getSession(Astro.request); } catch { return new Response('Auth not configured', { status: 500 }); } if (!session) { return Astro.redirect('/api/auth/signin'); } if (!isAdmin(session.user?.id)) { return new Response('Forbidden', { status: 403 }); } let entries: GuestbookEntry[] = []; try { entries = await getPendingEntries(); } catch { // handle error } function formatDate(date: Date): string { const d = String(date.getDate()).padStart(2, '0'); const m = String(date.getMonth() + 1).padStart(2, '0'); const y = String(date.getFullYear()).slice(-2); return `${d}/${m}/${y}`; } ---

guestbook admin

logged in as {session.user?.name} sign out

{entries.length === 0 ? (

no pending entries

) : ( )}