This project is a Node.js-based API for exploring GitHub organization repositories. The API supports both local and Dockerized environments. Follow the instructions below to set up and run the project.
Before you begin, make sure you have the following installed:
- Node.js (recommended version: 23 or later).
- pnpm (preferred package manager for this project).
- Docker and Docker Compose.
- A GitHub personal access token for API authentication.
To run the API locally:
- Clone the repository and install dependencies.
# clone repository
git clone git@github.com:francislagares/github-org-finder.git
# cd into
cd github-org-finder
# install required dependencies
pnpm install
The API requires the following environment variables. Configure these in a .env
or .env.development.local
file in the api directory.
GITHUB_SECRET=your_github_secret
REDIS_HOST=localhost
DATABASE_URL=mongodb://localhost:27017/repos_db
CORS_ORIGIN=http://localhost:5173
To run the API using pm2:
- Create a
.env.development.local
file in the api directory with the following Docker environment variables.
GITHUB_SECRET=your_github_secret
REDIS_HOST=localhost
DATABASE_URL=mongodb://localhost:27017/repos_db
CORS_ORIGIN=http://localhost:5173
- Run the following command:
pnpm pm2:dev
- Run the following command:
pnpm build:api
- Start the PM2 Daemon:
pnpm pm2:prod
You need to stop and clean the instance of pm2 before switching environment. Or just change ports in ecosystem.config.js file.
pnpm pm2:stop
pnpm pm2:clean
To run the API using Docker:
-
Ensure Docker and Docker Compose are installed and running on your system.
-
Create a
.env
or.env.development.local
file in the api directory with the following Docker environment variables.
GITHUB_SECRET=your_github_secret
REDIS_HOST=redis
DATABASE_URL=mongodb://mongodb:27017/repos_db
CORS_ORIGIN=http://localhost:5173
- Build and start the Docker containers:
docker-compose up --build
- Verify the API is running by accessing http://localhost:4000/api/v1/health
- URL:
/health
- Method:
GET
- Description: Checks if the API is running.
- URL:
/api/v1/orgs/:orgName/repos
- Method:
GET
- Query Parameters:
page
(optional): Page number for pagination (default is1
).limit
(optional): Limit number for repositories (default is10
).
- Description: Retrieves repositories for a given GitHub organization.
- URL:
/api/v1/repos/save
- Method:
POST
- Description: Saves repositories to the MongoDB database.
- URL:
/api/v1/repos/:id
- Method:
DELETE
- Description: Deletes a repository from the MongoDB database by its ID.
This project provides an API that you can interact with using Swagger, an interactive API documentation tool. To query the API correctly, you need to configure your environment with the GITHUB_SECRET token, which is required to access certain routes of the API.
Once the GITHUB_SECRET
variable is configured, you can access Swagger to explore and query the API.
- Swagger URL: http://localhost:4000/api-docs (adjust the port if needed).
When accessing the API documentation via Swagger, you need to authenticate using the GITHUB_SECRET
token. This is done via an HTTP header for routes that require authentication.
- Open the Swagger page in your browser.
- At the top, you'll find an "Authorize" button.
- Click on "Authorize".
- In the authentication field, enter your actual GITHUB_SECRET token for the
Authorization
header like so:
ghp_12345abcdef6789test
(Replace ghp_12345abcdef6789 with your actual GITHUB_SECRET token).
- Click "Authorize" to confirm.
Now you will be able to make authenticated requests to the API routes that require the GITHUB_SECRET token.
While the API is already functional the client side is still in development and additional features are being developed and refined.
Please check the client folder for the latest updates.
Contributions are more than welcomed.
Feel free to open issues for asking questions, suggesting features or other things!