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

Function githubRequest

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

Source from the content-addressed store, hash-verified

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

Callers 2

markStaleFunction · 0.70
closeExpiredFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected