flagon-io/g1t

public

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t/apps/web/app/routes/search-json.ts

19 lines788 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Search across all of g1t, Explore, and a command palette1/**
2 * What the command palette shows as someone types: a few repositories,
3 * issues, pull requests and people, as the viewer may see them. Signed out,
4 * public ones only.
5 */
6import type { Route } from "./+types/search-json";
7import { search } from "../lib/services.server";
8import { getViewer } from "../lib/session.server";
9
10export async function loader({ request, context }: Route.LoaderArgs) {
11 const q = (new URL(request.url).searchParams.get("q") ?? "").trim().slice(0, 256);
12 const headers = { "cache-control": "no-store" };
13 if (q.length < 2) return Response.json({ q, hits: [] }, { headers });
14 try {
15 return Response.json({ q, hits: await search.suggest(getViewer(context), q) }, { headers });
16 } catch {
17 return Response.json({ q, hits: [] }, { headers });
18 }
19}