diff --git a/README.md b/README.md index b820398..a7abb4d 100644 --- a/README.md +++ b/README.md @@ -126,3 +126,38 @@ https://github-profile-trophy.vercel.app/?username=ryo-ma&row=2&column=3 ``` + +# Contribution Guide + +## Environment + +* Deno >= v1.3.0 +* typescript >= 3.9.7 +* ![Vercel](https://vercel.com/) +* GitHub API v4 + +## Local Run + +Create `.env` file to project root directory, and write your GitHub token to the `.env` file. + +``` +GITHUB_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +``` + +Run local server. + +``` +deno run --allow-net --allow-read --allow-env debug.ts +``` + +## Editor config + +Read the ![.editorconfig](./.editorconfig) + +## Run deno lint + +If you want to contribute to my project, you should check the lint with the following command. + +``` +deno lint --unstable +``` \ No newline at end of file diff --git a/src/github_api_client.ts b/src/github_api_client.ts index 4235e3f..bed482b 100644 --- a/src/github_api_client.ts +++ b/src/github_api_client.ts @@ -14,6 +14,13 @@ export class UserInfo { ) { } } +type Language = { name: string }; +type Stargazers = { totalCount: number }; + +type Repository = { + languages: { nodes: Language[] }; + stargazers: Stargazers; +}; export class GithubAPIClient { constructor() { @@ -75,14 +82,14 @@ export class GithubAPIClient { userData.contributionsCollection.restrictedContributionsCount + userData.contributionsCollection.totalCommitContributions; const totalStargazers = userData.repositories.nodes.reduce( - (prev: number, node: any) => { + (prev: number, node: Repository) => { return prev + node.stargazers.totalCount; }, 0, ); const languages = new Set(); - userData.repositories.nodes.forEach((node: any) => { + userData.repositories.nodes.forEach((node: Repository) => { if (node.languages.nodes[0] != undefined) { languages.add(node.languages.nodes[0].name); }