aboutsummaryrefslogtreecommitdiffstats
path: root/src/services/repos/github.ts
blob: 37400ad3437e55e176a75d94147a2fad35d935ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { RepoData } from '@ts/types/github';

/**
 * Retrieve repository data from Github by slug.
 * @param repo - The repository slug.
 * @returns {Promise<RepoData>} - The repository data.
 */
export const getRepoData = async (repo: string): Promise<RepoData> => {
  const user = process.env.NEXT_PUBLIC_GITHUB_USER;
  const api = `https://api.github.com/repos/${user}/${repo}`;

  const response = await fetch(api);

  return response.json();
};