Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pradumnasaraf/contributors
Contributors is a GraphQL API written in Go. It uses MongoDB as a database to store and Redis to cache and rate limit the requests.
https://github.com/pradumnasaraf/contributors
docker docker-images gin go golang graphql kubernetes mongodb redis
Last synced: 3 months ago
JSON representation
Contributors is a GraphQL API written in Go. It uses MongoDB as a database to store and Redis to cache and rate limit the requests.
- Host: GitHub
- URL: https://github.com/pradumnasaraf/contributors
- Owner: Pradumnasaraf
- License: gpl-3.0
- Created: 2023-02-13T14:31:37.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-23T17:24:57.000Z (3 months ago)
- Last Synced: 2024-10-23T20:33:51.254Z (3 months ago)
- Topics: docker, docker-images, gin, go, golang, graphql, kubernetes, mongodb, redis
- Language: Go
- Homepage:
- Size: 99.6 KB
- Stars: 19
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
## Contributors
Contributors is a GraphQL API written in Go. It uses MongoDB as a database to store and Redis to cache and rate limit the requests. To deploy the project Kubernetes is used (manifests are available in the `Kubernetes` directory).
## Using and developing
### Local Development
Make sure you have [Go](https://golang.org/) and [MongoDB](https://www.mongodb.com/) installed. And you have alredy cloned the repository.
First, copy the `.env.example` file to `.env` and change the values to your own. You can use below bash command to do that.
```bash
cp .env.example .env
```Then, run the following commands to start the server.
```bash
go mod download
go run main.go
```### Gitpod
The easiest way to run this project in cloud with use of [Gitpod](https://www.gitpod.io/). Just click on the button below to start the project in Gitpod.
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#github.com/Pradumnasaraf/Contributors)
### Docker Compose
Make sure you have [Docker](https://www.docker.com/) and [Docker Compose](https://docs.docker.com/compose/) installed. And you have already cloned the repository.
Then, run the following commands to start the server. It will step up a MongoDB container and a Go API container.
```bash
docker compose up
```## Using the API
You can use the GraphQL Playground to interact with the API. It will be available at `http://localhost:8080/` if you are running the API locally.
### Queries
#### Add a new contributor
The `userId` for a contributor is the `U` + `githubUsername`. For example, if the `githubUsername` is `example`, then the `userId` will be `Uexample`. This is done to make sure that the `userId` is unique. `contributions` is optional in the input.
```graphql
mutation {
addAContributor(
input: {
githubUsername: "example"
name: "Pradumna Saraf"
email: "[email protected]"
contributions: {
projectName: "example"
type: "code"
date: "2021-09-01"
}
}
) {
userId
githubUsername
name
contributions {
contributionId
projectName
type
date
}
}
}
```#### Get all contributors
```graphql
query {
getAllContributors {
userId
githubUsername
name
}
}
```#### Get a contributor by userId
```graphql
query {
getAContributor(userId: "Uexample") {
userId
githubUsername
name
}
}
```#### Update a contributor by userId
In update we don't update the `userId` if `githubUsername` is changed. This is done to make sure that the `userId` is always remain same.
```graphql
mutation {
updateAContributor(
userId: "Uexample"
input: {
name: "example"
email: "[email protected]"
githubUsername: "example"
}
) {
userId
githubUsername
name
}
}
```#### Delete a contributor by userId
```graphql
mutation {
deleteAContributor(userId: "Uexample") {
userId
githubUsername
name
}
}
```#### Add a new contribution
The `contributionId` for a contribution is the `C` + `repositoryName`. For example, if the `repositoryName` is `example`, then the `contributionId` will be `Cexample`. This is done to make sure that the `contributionId` is unique.
```graphql
mutation {
addAContribution(
userId: "Uexample"
input: { projectName: "example", type: "code", date: "2021-09-01" }
) {
contributionId
}
}
```#### Delete a contribution
```graphql
mutation {
deleteAContribution(contributionId: "Cexample") {
contributionId
}
}
```####
## License
This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) for details.
## Security
If you discover a security vulnerability within this project, please check the [security policy](SECURITY.md) for more information.