From e3d378ccdcb7ee0829a79a83e26228faef3ad417 Mon Sep 17 00:00:00 2001 From: r-freeman Date: Sat, 28 Jan 2023 22:12:58 +0000 Subject: [PATCH] Added github username env variable --- .env.example | 3 ++- lib/github.ts | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index ae88d0a..74cad7f 100644 --- a/.env.example +++ b/.env.example @@ -4,4 +4,5 @@ SPOTIFY_REFRESH_TOKEN= NEXT_PUBLIC_SITE_URL=https://example.com DATABASE_URL= SHADOW_DATABASE_URL= -GITHUB_ACCESS_TOKEN= \ No newline at end of file +GITHUB_ACCESS_TOKEN= +GITHUB_USERNAME= \ No newline at end of file diff --git a/lib/github.ts b/lib/github.ts index 2bb4057..e4fff0c 100644 --- a/lib/github.ts +++ b/lib/github.ts @@ -2,6 +2,7 @@ import type {Repo} from '@/types' import fetcher from "@/lib/fetcher"; const GITHUB_ACCESS_TOKEN = process.env.GITHUB_ACCESS_TOKEN +const GITHUB_USERNAME = process.env.GITHUB_USERNAME const GITHUB_GRAPHQL = "https://api.github.com/graphql" type PinnedReposResponse = { @@ -59,7 +60,7 @@ export async function getPinnedRepos() { }, body: JSON.stringify({ query: `{ - user(login: "r-freeman") { + user(login: "${GITHUB_USERNAME}") { pinnedItems(first: 6, types: REPOSITORY) { nodes { ... on Repository { @@ -92,7 +93,7 @@ export async function getTotalRepos() { }, body: JSON.stringify({ query: `{ - user(login: "r-freeman") { + user(login: "${GITHUB_USERNAME}") { repositories { totalCount } @@ -113,7 +114,7 @@ export async function getTotalFollowers() { }, body: JSON.stringify({ query: `{ - user(login: "r-freeman") { + user(login: "${GITHUB_USERNAME}") { followers { totalCount } @@ -134,7 +135,7 @@ export async function getTotalStars(totalRepos: number) { }, body: JSON.stringify({ query: `{ - user(login: "r-freeman") { + user(login: "${GITHUB_USERNAME}") { repositories(first: ${totalRepos}) { nodes { stargazers {