Skip to content

Commit 56b34c7

Browse files
committed
Fetch the comments using gh.js
1 parent 4df72f0 commit 56b34c7

File tree

5 files changed

+34
-22
lines changed

5 files changed

+34
-22
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.swp
2+
*.swo
3+
*~
4+
*.log
5+
node_modules

example/index.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

lib/index.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"version": "1.0.0",
1616
"main": "lib/index.js",
1717
"scripts": {
18-
"test": "echo \"Error: no test specified\" && exit 1"
18+
"start": "node server"
1919
},
2020
"author": "Ionică Bizău <[email protected]> (https://ionicabizau.net)",
2121
"homepage": "https://github.com/IonicaBizau/github-comments#readme",
@@ -36,5 +36,9 @@
3636
},
3737
"bugs": {
3838
"url": "https://github.com/IonicaBizau/github-comments/issues"
39+
},
40+
"dependencies": {
41+
"gh.js": "^3.0.8",
42+
"lien": "^2.2.6"
3943
}
40-
}
44+
}

server.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const Lien = require("lien")
2+
, GitHub = require("gh.js")
3+
;
4+
5+
const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
6+
7+
const server = new Lien()
8+
, ghClient = new GitHub(GITHUB_TOKEN)
9+
;
10+
11+
server.addPage("/:owner/:name", lien => {
12+
debugger
13+
ghClient.get(`repos/${lien.params.owner}/${lien.params.name}/issues/comments`, {
14+
all: true
15+
}, (err, allComments) => {
16+
if (err) { return lien.apiError(err); }
17+
lien.end(allComments);
18+
});
19+
});
20+
21+
server.on("serverError", err => {
22+
console.error(err.stack);
23+
});

0 commit comments

Comments
 (0)