MCPcopy Create free account
hub / github.com/anthropics/claude-code / githubRequest

Function githubRequest

scripts/sweep.ts:18–44  ·  view source on GitHub ↗
(
  endpoint: string,
  method = "GET",
  body?: unknown
)

Source from the content-addressed store, hash-verified

16// --
17
18async function githubRequest<T>(
19 endpoint: string,
20 method = "GET",
21 body?: unknown
22): Promise<T> {
23 const token = process.env.GITHUB_TOKEN;
24 if (!token) throw new Error("GITHUB_TOKEN required");
25
26 const response = await fetch(`https://api.github.com${endpoint}`, {
27 method,
28 headers: {
29 Authorization: `Bearer ${token}`,
30 Accept: "application/vnd.github.v3+json",
31 "User-Agent": "sweep",
32 ...(body && { "Content-Type": "application/json" }),
33 },
34 ...(body && { body: JSON.stringify(body) }),
35 });
36
37 if (!response.ok) {
38 if (response.status === 404) return {} as T;
39 const text = await response.text();
40 throw new Error(`GitHub API ${response.status}: ${text}`);
41 }
42
43 return response.json();
44}
45
46// --
47

Callers 2

markStaleFunction · 0.70
closeExpiredFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected