A web application with insights into Github data. Gives data of popular repositories on github.
- see the
package.json
- type
npm install
- type
bower install
- open console type
gulp serve
- First, go to your GitHub profile settings and define a Personal access token (https://github.com/settings/tokens)
- Then, add the token to the environment variables (eg:
export TOKEN_GITHUB_DOT_COM=token_string
) - Now you can get the token like that:
process.env.TOKEN_GITHUB_DOT_COM
const GitHubClient = require('../libs/GitHubClient.js').GitHubClient;
let githubCliEnterprise = new GitHubClient({
baseUri: "http://github.at.home/api/v3",
token: process.env.TOKEN_GHITHUB_ENTERPRISE
});
let githubCliDotCom = new GitHubClient({
baseUri:"https://api.github.com",
token: process.env.TOKEN_GITHUB_DOT_COM
});
- if you use GitHub Enterprise,
baseUri
has to be set withhttp(s)://your_domain_name/api/v3
- if you use GitHub.com,
baseUri
has to be set withhttps://api.github.com
For example, you want to get the information about a user: (see https://developer.github.com/v3/users/#get-a-single-user)
let githubCliEnterprise = new GitHubClient({
baseUri:"http://github.at.home/api/v3",
token:process.env.TOKEN_GHITHUB_ENTERPRISE
});
var handle = "k33g";
githubCliEnterprise.getData({path:`/users/${handle}`})
.then(response => {
console.log(response.data);
});
You can add "features" to GitHubClient
(like traits):
const GitHubClient = require('../libs/GitHubClient.js').GitHubClient;
const octocat = require('../libs/features/octocat');
const users = require('../libs/features/users');
// add octocat and users features to GitHubClient
let githubCli = new GitHubClient({
baseUri:"http://github.at.home/api/v3",
token:process.env.TOKEN_GHITHUB_ENTERPRISE
}, octocat, users);
githubCli.octocat()
.then(data => {
// display the Zen of Octocat
console.log(data);
})
githubCli.fetchUser({handle:'k33g'})
.then(user => {
// all about @k33g
console.log(user);
})
More samples to come