import { listPendingApprovals } from "../../../db/device-approvals";

/**
 * GET /api/devices/approvals
 *
 * Listet alle pending Approval-Requests des Users. Existing Devices rufen das
 * beim Start auf (in case realtime missed an event) und beim Realtime-Trigger.
 */
export default defineEventHandler(async (event) => {
  const user = await requireUser(event);
  const approvals = await listPendingApprovals(user.id);
  return { approvals };
});
