MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / fetchStars

Function fetchStars

site/src/lib/github.ts:17–35  ·  view source on GitHub ↗
(fallback: string)

Source from the content-addressed store, hash-verified

15}
16
17async function fetchStars(fallback: string): Promise<string> {
18 try {
19 const controller = new AbortController();
20 const timeout = setTimeout(() => controller.abort(), 3000);
21 const res = await fetch('https://api.github.com/repos/colbymchenry/codegraph', {
22 headers: {
23 Accept: 'application/vnd.github+json',
24 'User-Agent': 'codegraph-site',
25 },
26 signal: controller.signal,
27 });
28 clearTimeout(timeout);
29 if (!res.ok) return fallback;
30 const data = (await res.json()) as { stargazers_count?: number };
31 return typeof data.stargazers_count === 'number' ? format(data.stargazers_count) : fallback;
32 } catch {
33 return fallback;
34 }
35}
36
37let cached: Promise<string> | null = null;
38

Callers 1

getStarsLabelFunction · 0.85

Calls 2

formatFunction · 0.85
fetchFunction · 0.50

Tested by

no test coverage detected