diff options
Diffstat (limited to 'src/services/repos')
| -rw-r--r-- | src/services/repos/github.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/services/repos/github.ts b/src/services/repos/github.ts new file mode 100644 index 0000000..37400ad --- /dev/null +++ b/src/services/repos/github.ts @@ -0,0 +1,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(); +}; |
