import { db } from "~~/server/lib/db"; export default defineEventHandler(async (event) => { await protectRoute(event); const userId = event.context.user!.id as string; const agents = await db.query.agents.findMany({ where: { userId, }, orderBy: { createdAt: 'asc', }, with: { topics: { orderBy: { createdAt: 'desc', }, } } }); return agents; })