14 lines · 622 BRaw
| 1 | import type { Route } from "./+types/repo-live"; |
| 2 | import { refsErrorCode } from "@refs/backend/contract"; |
| 3 | import { refs, fullName } from "../lib/session"; |
| 4 | |
| 5 | export async function loader({ params, request, context }: Route.LoaderArgs) { |
| 6 | const task = Number(new URL(request.url).searchParams.get("task")) || undefined; |
| 7 | try { |
| 8 | const repo = await refs(context).repo(fullName(params)); |
| 9 | return Response.json({ latest: await repo.latest(task) }, { headers: { "cache-control": "no-store" } }); |
| 10 | } catch (error) { |
| 11 | if (refsErrorCode(error)) return Response.json({ latest: 0 }, { status: 404 }); |
| 12 | throw error; |
| 13 | } |
| 14 | } |