import { createFileRoute } from "@tanstack/react-router";
import { getSessionSnapshots, getSessions } from "../../proxy/store";

export const Route = createFileRoute("/api/sessions")({
  server: {
    handlers: {
      GET: ({ request }: { request: Request }) => {
        const url = new URL(request.url);
        const details = url.searchParams.get("details");
        if (details === "true" || details === "1") {
          return Response.json(getSessionSnapshots());
        }
        return Response.json(getSessions());
      },
    },
  },
});
