Skip to content

PsaiduPL/Atiperia_task

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Repository Lister API

A simple REST API that fetches a list of a specified user's public, non-forked GitHub repositories, along with branch information for each.

Table of Contents

  1. Project Overview
  2. Getting Started
  3. API Documentation
  4. Technologies Used

Project Overview

This application provides a single REST endpoint that interacts with the public GitHub API. When given a GitHub username, the service retrieves a list of their repositories that are not forks. For each repository, the API also appends a list of its branches, including the branch name and the SHA of its latest commit.

Getting Started

Prerequisites

  • Java 21 or newer

Additional

  • GitHub Personal Access Token for more requestes

Configuration

To avoid hitting the GitHub API's strict rate limits for unauthenticated requests, the application accepts a Personal Access Token.

You can configure the token in one of the following ways:

  1. Environment Variable (Recommended): Set an environment variable named GIT_API_KEY with your token value.

    export GIT_API_KEY="ghp_YourPersonalAccessToken"
  2. Properties File: Add the following line to the src/main/resources/application.properties and test/main/resources/application-test.properties:

    passwd.gittoken=ghp_YourPersonalAccessToken
  3. Additional step for caching If you want version which contains caching, switch to branch feature/caching and enter settings you want for caching.

     spring.cache.caffeine.spec=maximumSize=500,expireAfterWrite=1m

Installation & Running

  1. Clone the repository
    git clone https://github.com/PsaiduPL/Atiperia_task.git
    cd Atiperia_task

Main Version is on branch main.

  1. Run the application using the Maven wrapper
    ./mvnw spring-boot:run
    The application will start on the default port 8080.

API Documentation

Get User Repositories

Retrieves a list of non-forked repositories and their branches for a given GitHub user.

  • URL: /api/{nickname}
  • Method: GET
  • URL Params:
Parameter Type Description
nickname String Required. The GitHub username.

Sample Request (cURL)

curl http://localhost:8080/api/Exampl

Success Response (200 OK)

Returns a JSON array of repository objects.

[
  {
    "login": "Exampl",
    "repositoryName": "ExamCI",
    "branches": [
      {
        "name": "master",
        "sha": "3891d715ad0f4903d1eab5877e05a721fe2553a7"
      }
    ]
  }
]

Error Responses

  • Code: 404 Not Found
    Reason: The user with the provided nickname does not exist on GitHub.

    {
    "status": 404,
    "message": "User doesn't exists"
    }
  • Code: 500 Internal Server Error
    Reason: An unexpected server-side error occurred while processing the request.

  • Code: 503 Service Unavailable
    Reason: The service is temporarily unavailable, likely due to issues communicating with the GitHub API.

Technologies Used

  • **Spring Boot ** - Core framework
  • Java 21 - Programming language
  • Maven - Dependency management and build tool
  • Spring Web (RestTemplate) - For communicating with the external REST API

About

task for interview in Atipera

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages