Skip to content

Commit cbaa64b

Browse files
committed
tweaked the compare name func
1 parent 4dcee42 commit cbaa64b

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

funcs/compareHashes.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
const compareHashes = {
22
compareName: function(sha, response) {
3+
let present = false
34
response.map(res => {
45
if (res.name === sha) {
5-
return true
6+
present = true
67
}
78
})
8-
return false
9+
return present
910
}
10-
}
11+
}
12+
13+
module.exports = compareHashes;

index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var app = express();
44
const atob = require('atob');
55
const KEY = require('./key');
66
const Base64 = require('base-64');
7+
const compareHash = require('./funcs/compareHashes')
78

89
app.use(cors())
910

@@ -81,7 +82,11 @@ app.get('/add-sha/:sha', (req, res) => {
8182
Axios.get("https://api.github.com/repos/ujjwal-kr-data/ip-data/contents/", {
8283
headers: {'Authorization': "token " + KEY}
8384
}).then(getRes => {
84-
console.log(getRes.data)
85+
if (compareHash.compareName(req.params.sha, getRes.data) === true) {
86+
console.log("yes")
87+
} else {
88+
console.log("no")
89+
}
8590
return res.json({message: "done"})
8691
// Axios.put("https://api.github.com/repos/ujjwal-kr-data/ip-data/contents/"+req.params.sha, {
8792
// message: "Added a document",

0 commit comments

Comments
 (0)