- Node 18
-
Clone repo, run
npm installandnpm run dev -
Create a
.envfile in the following format:ACCESS_TOKEN=<GitHub personal access token> USERNAME=<GitHub username>
❗ Without the .env file there will be a 50-request hourly limit on the API.
Visit this WEB APP to see the API in action.
This app is a thin wrapper around the GitHub API.
It currently supports an endpoint to fetch open pull requests of a repo, along with the commits of each pr.
[GET] https://pr-app.herokuapp.com/api/openprs?repo={repo}&limit={limit}&page={page}
/*
[GET] https://pr-app.herokuapp.com/api/openprs?repo=https://github.com/expressjs/express&limit=1&page=1
Example of response:
{
"github_api": {
"url": "https://api.github.com/repos/expressjs/express/pulls?state=open&per_page=1&page=1",
"rate_limit": 4948
},
"links": {
"next": {
"url": "https://pr-app.herokuapp.com/api/openprs?repo=https://github.com/expressjs/express&limit=1&page=2"
},
"last": {
"url": "https://pr-app.herokuapp.com/api/openprs?repo=https://github.com/expressjs/express&limit=1&page=53"
}
},
"data": [
{
"id": 1165838603,
"number": 5063,
"title": "chore: Add Node.js version 19",
"commit_count": 1,
"commits": [
"chore: Add Node.js version 19"
]
}
]
}
/*repoURL of GitHub repo. It will respond with a 422 on incorrect format, or 404 on not found.limitbetween 1 and 100. It will default to 1 for values outside the range.pagebetween 1 and 100. It will default to 1 for values outside the range.
- Scalable architecture, more endpoints could be added in a maintainable manner.
- Endpoint supports four different formats for the repo URL (credit for Regex to Hicham)
- Endpoint simple to use, on improper page & limit params 1 & 1 are used.
- Pagination of results.
- Will list 250 commits per pull request max.
- Dependant on the GitHub API rate limits.
- Run
npm test
- ❗ Tests are hitting the live Github API which is not great.
- ❗ Tests should intercept such calls and mock a small response.
- ❗ Too many fetch requests (max 100) necessary to grab the commits of the pull requests.
- ❗ Uses Basic auth with a GitHub personal access token (hourly 5000 request limit).
- ❗ Error due to rate limit exceeded not handled properly.