Skip to content

Commit 870b372

Browse files
author
Henri Van den Braembussche
committed
sort repos
1 parent 23ffc32 commit 870b372

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

app.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,24 @@ var corsOptions = {
2121
app.get('/members',cors(corsOptions), githubWebhook.getMembers);
2222
app.get('/repos',cors(corsOptions), githubWebhook.getRepos);
2323

24+
/*
25+
const PORT = process.env.PORT || 2900;
26+
app.listen(PORT, () => {
27+
var options = {
28+
uri: 'https://api.github.com/orgs/lab9k/repos',
29+
headers: {
30+
'User-agent':'henrivdb',
31+
Authorization: 'token '+ process.env.GITHUB_PERSONAL_ACCESS_TOKEN,
32+
}
33+
};
34+
35+
request.get(options, function (error, response, body) {
36+
var sortedBody = JSON.parse(body).sort(function(a, b) {
37+
return parseFloat(b.pushed_at) - parseFloat(a.pushed_at);
38+
});
39+
console.log(sortedBody);
40+
});
41+
});
42+
*/
43+
2444
module.exports = app;

src/githubWebhook.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ module.exports= {
1313
};
1414

1515
request.get(options, function (error, response, body) {
16+
if(error != null)
17+
{
18+
console.log('error:', error);
19+
}
1620
res.status(200).send(body);
17-
console.log('error:', error); // Print the error if one occurred
1821
});
1922

2023
},
@@ -30,8 +33,14 @@ module.exports= {
3033
};
3134

3235
request.get(options, function (error, response, body) {
33-
res.status(200).send(body);
34-
console.log('error:', error); // Print the error if one occurred
36+
if(error != null)
37+
{
38+
console.log('error:', error);
39+
}
40+
var sortedBody = JSON.parse(body).sort(function(a, b) {
41+
return parseFloat(b.pushed_at) - parseFloat(a.pushed_at);
42+
});
43+
res.status(200).send(sortedBody);
3544
});
3645

3746
},

0 commit comments

Comments
 (0)