diff --git a/index.ts b/index.ts index ebd13e7..d28106f 100644 --- a/index.ts +++ b/index.ts @@ -6,9 +6,17 @@ type repo = { } type repos = repo[] +const fetchOpts: RequestInit = {} + +if (process.env.AuthorizationHeaderToken) { + fetchOpts.headers = { + "Authorization": `Bearer ${process.env.AuthorizationHeaderToken}` + } +} + const getTopLangs = async (type: "users" | "orgs", name: string) => { const obj: Record = {} - const userRepoResp = await fetch(`https://git.creations.works/api/v1/${type}/${name}/repos?limit=0`); + const userRepoResp = await fetch(`https://git.creations.works/api/v1/${type}/${name}/repos?limit=0`, fetchOpts); const userRepos = await userRepoResp.json() as repos; for (const repo of userRepos) {