This is a Spring Boot application that serves as an API for retrieving information about GitHub repositories.
- Java 21
- Spring Boot 3
- Maven
- Mockito
- Postman for endpoints testing
- Clone the repository.
- Ensure you have Java and Maven installed.
- Configure your GitHub access token in the application.properties file. Check the Github-token section.
- Build and run the application using preferred IDE.
In order for application to work, you must declare the 'accessToken' field with your GitHub access token in the application.properties file:
accessToken=your_generated_gh_access_token
I recomend for github personal token listed scopes:
- repo:status,
- public_repo,
- read:user.
The application has two endpoints healthcheck (returns OK http status) and the endpoint that performs the task (lists info about the repositories).
To use the Repository Info API, make a GET request to the /api/repositories/{username} endpoint, where {username} is the GitHub username of the user whose repositories you want to retrieve.
The endpoint returns JSON object with the information about user's repository or
in case of exceptions, the exception code with message what happened.
This endpoint handles and produces suitable message for listed reasons:
- x-rate limit (403 and 429 http status codes),
- when user does not exist (404 http status code),
- if wrong JSON format is sent (400 status code),
- if wrong parameters are sent (422 status code).
Successful Response
{
"Owner Login": "example-user",
"Branches": [
{
"Branch Name": "main",
"Commit sha": "abc123"
},
{
"Branch Name": "feature-branch",
"Commit SHA": "def456"
}
],
"Repository Name": "example-repo"
}
Error Responses
- 404 Not Found: If the specified GitHub user does not exist.
{
"status": 404,
"message": "User not found"
}
Unit tests have been made with the usage of the Mockito framework.
- Maria Kranz