Skip to content

Babanila/search-service

Repository files navigation

Search-Service

Overview of Search-Service

The Search-Service provides a single API endpoint to search for GitHub users by specifying a programming language they use in their public repositories and a username string.

Modules

The Search-Service combines different npm modules for it to work normally:

  • Nodejs
  • Express
  • Got
  • Jest

Table of Contents

Features

Search-Service is a backend service with a single API endpoint that return git users with the below properties:-

  • Username
  • Name
  • Avatar URL
  • Number of followers

Requirements

  • Install git, node, npm.
  • Download Code Editor of your choice (VSCode recommended).
  • Clone the repo ( link or use git clone [email protected]:Babanila/search-service.git).
  • Go into root of the cloned directory and run npm install.
  • Open the editor (VSCode) and locate the downloaded directory to start developing (or with code . in the project director on your terminal).

How To Start The Server From The Root Directory

  • To start the server, from the root directory run npm run start or node server.js.
  • Open web browser and gotohttp://localhost:8080/get-users

Usage

  • Goto http://localhost:8080/get-users

  • Add query parameters, username and language (must be supplied).

    E.g - http://localhost:8080/get-users?username=adam&language=javascript

    - http://localhost:8080/get-users?username=john&language=java,go

  • Press enter button.

Test

  • From the root directory run npm run test.

For Docker Usage

Login to Docker

  • Install docker on your system(Docker link).

  • Create docker account (Create docker account).

  • Login to docker.

  • Then the below docker commands can be carried out.

To create docker image

  • docker build -t <docker_username>/node-search-app .

    E.g docker build -t babanila/node-search-app .

To push the docker image to personal account

  • docker push <docker_username>/node-search-app

    E.g docker push babanila/node-search-app:latest

To pull the docker image from dockerhub

  • docker pull <docker_username>/node-search-app

    E.g docker pull babanila/node-search-app

To run docker image in container

  • docker run --publish 3000:8080 --detach --name

    E.g docker run --publish 3000:8080 --detach --name test1 <docker_username>/node-search-app:latest

Test the connection

  • Add the query parameters (username and language) to the url localhost:3000/get-users

    E.g curl -i http://localhost:3000/get-users?username=babanila&language=javascript

Note

In other for this solution to be well tested considering the rate limitation imposed by Github API for usage without Basic Authentication or OAuth (up to 5000 requests per hour), the search result output can be limited to a certain number like 10, 20 etc.

In the Controller.js file on line 62, can be changed to searchResults.slice(0,10), for the first 10 search results.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published