GitHub Statistics

node v4.9.1
version: 1.0.0
endpointsharetweet
const getJSON = require("async-get-json"); exports.getCommitActivity = async function (props) { const normalized = typeof props === "string" ? { repo: props } : props; const [user, repo] = normalized.repo.includes("/") ? normalized.repo.split("/") : [normalized.user, normalized.repo]; const COMMIT_ACTIVITY_API = `https://api.github.com/repos/${user}/${repo}/stats/commit_activity`; const items = await getJSON(COMMIT_ACTIVITY_API); // Return last week so we have a full week. return items[items.length - 2]; } exports.getMostPopularRepos = async function({ limit }) { const POPULAR_REPOS_API = "https://api.github.com/search/repositories"; const query = `?q=javascript&sort=stars&order=desc&per_page=${limit}`; return (await getJSON(POPULAR_REPOS_API + query)).items; }
Loading…

no comments

    sign in to comment