-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
203 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Octokit } from 'octokit'; | ||
|
||
let cachedGithubStarCountPromise: null | Promise<number> = null; | ||
|
||
export async function fetchGithubStarCount() { | ||
if (cachedGithubStarCountPromise !== null) { | ||
// If the promise is in the cache, return it directly | ||
return cachedGithubStarCountPromise; | ||
} | ||
|
||
cachedGithubStarCountPromise = (async () => { | ||
try { | ||
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN }); | ||
const responseData = await octokit.request('GET /repos/{owner}/{repo}', { | ||
owner: 'nrwl', | ||
repo: 'nx', | ||
headers: { | ||
'X-GitHub-Api-Version': '2022-11-28', | ||
}, | ||
retry: { enabled: false }, | ||
throttle: { | ||
enabled: true, | ||
}, | ||
}); | ||
|
||
return responseData.data.stargazers_count; | ||
} catch (e) { | ||
return 0; // fallback, will hide GitHub star widget | ||
} | ||
})(); | ||
|
||
return cachedGithubStarCountPromise; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
bdcec6d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nx-dev – ./
nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx-dev-nrwl.vercel.app
nx.dev