import { NextResponse } from 'next/server' import { auth } from '@/auth' import prisma from '@/lib/prisma' export async function GET() { const session = await auth() if (!session?.user?.id) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }) const notes = await prisma.note.findMany({ where: { userId: session.user.id, isPublic: true, trashedAt: null }, select: { id: true, title: true, publicSlug: true, publishedAt: true }, orderBy: { publishedAt: 'desc' }, }) return NextResponse.json({ notes }) }