Skip to content

Commit dc5eade

Browse files
committed
added final add func
1 parent cbaa64b commit dc5eade

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

index.js

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -78,28 +78,16 @@ app.get('/generate/:data', async (req, res) => { // Because URL PARAMS ARE COOLE
7878
})
7979

8080
app.get('/add-sha/:sha', (req, res) => {
81-
const encoded = Base64.encode(req.params.sha);
82-
Axios.get("https://api.github.com/repos/ujjwal-kr-data/ip-data/contents/", {
83-
headers: {'Authorization': "token " + KEY}
84-
}).then(getRes => {
85-
if (compareHash.compareName(req.params.sha, getRes.data) === true) {
86-
console.log("yes")
87-
} else {
88-
console.log("no")
89-
}
90-
return res.json({message: "done"})
91-
// Axios.put("https://api.github.com/repos/ujjwal-kr-data/ip-data/contents/"+req.params.sha, {
92-
// message: "Added a document",
93-
// content: encoded
94-
// }, {
95-
// headers: {'Authorization': "token " + KEY}
96-
// }).then(res => {
97-
// console.log(res.data)
98-
// }).catch(e => {
99-
// console.log(e)
100-
// })
81+
const encoded = Base64.encode(1);
82+
Axios.put("https://api.github.com/repos/ujjwal-kr-data/ip-data/contents/" + req.params.sha, {
83+
message: "Added a document",
84+
content: encoded
85+
}, {
86+
headers: { 'Authorization': "token " + KEY }
87+
}).then(res => {
88+
return res.json({ message: "created" })
10189
}).catch(e => {
102-
console.log(e)
90+
return res.json({ message: "exists" })
10391
})
10492
})
10593

0 commit comments

Comments
 (0)