GitHub Battle Clone with Vue.js and GraphQL
- Enter in two Github usernames, and it'll declare a winner.
- Validate each username entered with the GitHub API to make sure they exist.
- user score = (3 * nb_followers) + nb_stars_for_his_repos
- show each user's info
- avatar
- username
- full name
- location
- followers count
- following count
- public repos count
- blog url
- View a list of popular repos.
- filter by language(s)
- all languages
- or type a language (JavaScript, Java, Python, etc.)
- sort results by stars in descending order
- show each repo's info
- name
- link to the repo
- owner
- name
- avatar
- star count
- filter by language(s)
In order to protect the GitHub API key(s) in the production environment, the API calls are done with the help of a backend/web server. Unlike in the frontend, we can hide the API token(s) in the backend.
npm install
npm run serve
Create your project in the Firebase console.
npm install -g firebase-tools
firebase login
npm run build
firebase init
firebase deploy
- Create an Express Project on Glitch
- Add your GitHub API Token in the
.env
file. - Add these dependencies in the
package.json
file:- cors
- body-parser
- axios
- Create a new route to serve as an intermediate between the frontend and the GitHub API, as shown below.
app.post("/api", async (req, res) => {
let config = {
"headers": { "Authorization": `Token ${process.env.GITHUB_API_TOKEN}` }
};
let response = await axios.post("https://api.github.com/graphql", { "query": req.body.query }, config);
res.json(response.data);
});