-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
28 lines (24 loc) · 883 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const cal = require("./calculate_stats");
const grabRepos = require("./fetchers/grab-repos");
const buildTemplate = require("./temp_builder");
function parseReq(username, title) {
if (!title) {
title = `${username}'s GitHub Stats`
}
return new Promise( (resolve, reject) => {
grabRepos(username, async (repos) => {
const stars = cal.totalStars(repos)
const commits = await cal.totalCommits(username)
const prs = await cal.totalPrs(username)
const issues = await cal.totalIssues(username);
console.log()
if (!stars || !commits || !prs || !issues || !repos) {
reject("Error")
}
resolve(
buildTemplate({title,stars,commits,prs,issues,repos:repos.length})
)
})
})
}
module.exports = parseReq