Contribution page #71

Open
KevinMidboe wants to merge 3 commits from feat/contribution_page into master
2 changed files with 36 additions and 0 deletions
Showing only changes of commit 3e84f0e40f - Show all commits

33
api/github.js Normal file
View File

@@ -0,0 +1,33 @@
const fetch = require('node-fetch')
class Github {
constructor(apiToken) {
this.apiToken = apiToken;
this.hostname = "https://api.github.com"
}
listRepositoryContributors() {
const headers = {
"Accept": "application/json",
"Authorization": `token ${ this.apiToken }`
};
const url = `${ this.hostname }/repos/KevinMidboe/vinlottis/contributors`
return fetch(url, { headers })
.then(resp => resp.json())
.then(contributors =>
contributors.map(contributor => new Contributor(contributor))
);
}
}
class Contributor {
constructor(contributorObject) {
this.name = contributorObject.login;
this.avatarUrl = contributorObject.avatar_url;
this.profileUrl = contributorObject.html_url;
this.projectContributions = contributorObject.contributions;
}
}
module.exports = Github;

View File

@@ -16,6 +16,7 @@ const virtualRegistrationApi = require(path.join(
));
const lottery = require(path.join(__dirname, "/lottery"));
const chatHistoryApi = require(path.join(__dirname, "/chatHistory"));
const githubController = require(path.join(__dirname, "/controllers/githubController"));
const router = express.Router();
@@ -63,6 +64,8 @@ router.post('/winner/:id', virtualRegistrationApi.registerWinnerSelection);
router.get('/chat/history', chatHistoryApi.getAllHistory)
router.delete('/chat/history', mustBeAuthenticated, chatHistoryApi.deleteHistory)
router.get("/project/contributors", githubController.getProjectContributors);
router.post('/login', userApi.login);
router.post('/register', mustBeAuthenticated, userApi.register);
router.get('/logout', userApi.logout);