MCPcopy Index your code
hub / github.com/simstudioai/sim / getGitHubStars

Function getGitHubStars

apps/sim/lib/github/stars.ts:30–55  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28 * never throws.
29 */
30export async function getGitHubStars(): Promise<string> {
31 try {
32 const token = env.GITHUB_TOKEN
33 const response = await fetch('https://api.github.com/repos/simstudioai/sim', {
34 headers: {
35 Accept: 'application/vnd.github+json',
36 'X-GitHub-Api-Version': '2022-11-28',
37 'User-Agent': 'Sim/1.0',
38 ...(token ? { Authorization: `Bearer ${token}` } : {}),
39 },
40 next: { revalidate: 3600 },
41 cache: 'force-cache',
42 })
43
44 if (!response.ok) {
45 logger.warn('GitHub API request failed:', response.status)
46 return formatStarCount(FALLBACK_STAR_COUNT)
47 }
48
49 const data = await response.json()
50 return formatStarCount(Number(data?.stargazers_count ?? FALLBACK_STAR_COUNT))
51 } catch (error) {
52 logger.warn('Error fetching GitHub stars:', error)
53 return formatStarCount(FALLBACK_STAR_COUNT)
54 }
55}

Callers 2

LandingShellFunction · 0.90
route.tsFile · 0.90

Calls 2

formatStarCountFunction · 0.85
warnMethod · 0.65

Tested by

no test coverage detected