Skip to content

g1t/apps/web/app/routes/repo/about-json.ts

15 lines679 bytesCodeBlame
1/**
2 * The Files page's About as JSON, asked for again by the panel while the
3 * default branch is first being read (components/repo-about.tsx).
4 */
5import { data } from "react-router";
6
7import type { Route } from "./+types/about-json";
8import { repos } from "../../lib/services.server";
9import { getViewer } from "../../lib/session.server";
10
11export async function loader({ params, context }: Route.LoaderArgs) {
12 const found = await repos.about({ namespace: params.owner, name: params.repo }, getViewer(context));
13 if (!found.ok) throw data({ error: found.error.message }, { status: 404 });
14 return Response.json(found.value, { headers: { "cache-control": "no-store" } });
15}