import { NextResponse } from "next/server";
import { db } from "@/db";
import { verifySession } from "@/lib/auth";
import { patients } from "@/db/schema";

export async function GET() {
  const session = await verifySession();
  if (!session) {
    return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
  }

  const allPatients = await db.select().from(patients);
  return NextResponse.json({ patients: allPatients });
}
