Skip to content

Commit 4dcee42

Browse files
committed
added compare hash func
1 parent 4890d4d commit 4dcee42

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

funcs/compareHashes.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const compareHashes = {
2+
compareName: function(sha, response) {
3+
response.map(res => {
4+
if (res.name === sha) {
5+
return true
6+
}
7+
})
8+
return false
9+
}
10+
}

index.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,25 @@ app.get('/generate/:data', async (req, res) => { // Because URL PARAMS ARE COOLE
7777
})
7878

7979
app.get('/add-sha/:sha', (req, res) => {
80-
const encoded = Base64.encode(req.params.sha)
81-
Axios.put("https://api.github.com/repos/ujjwal-kr-data/ip-data/contents/"+req.params.sha, {
82-
message: "Added a document",
83-
content: encoded
84-
}, {
80+
const encoded = Base64.encode(req.params.sha);
81+
Axios.get("https://api.github.com/repos/ujjwal-kr-data/ip-data/contents/", {
8582
headers: {'Authorization': "token " + KEY}
86-
}).then(res => {
87-
console.log(res.data)
83+
}).then(getRes => {
84+
console.log(getRes.data)
85+
return res.json({message: "done"})
86+
// Axios.put("https://api.github.com/repos/ujjwal-kr-data/ip-data/contents/"+req.params.sha, {
87+
// message: "Added a document",
88+
// content: encoded
89+
// }, {
90+
// headers: {'Authorization': "token " + KEY}
91+
// }).then(res => {
92+
// console.log(res.data)
93+
// }).catch(e => {
94+
// console.log(e)
95+
// })
8896
}).catch(e => {
8997
console.log(e)
9098
})
91-
return res.json({message: "Created"})
9299
})
93100

94101
const port = process.env.PORT || 4000;

0 commit comments

Comments
 (0)