Skip to content

Commit 4890d4d

Browse files
committed
added basic data
1 parent 8f59002 commit 4890d4d

File tree

5 files changed

+30
-13
lines changed

5 files changed

+30
-13
lines changed

client/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ <h1>EPIC_Tracker</h1>
4444
<br>
4545
<p class="hash"></p>
4646
<code>
47-
The HASH is a unique identifier for you device configurations so even if you will visit the page in a
47+
The HASH is a unique identifier for your device configurations so even if you will visit the page in a
4848
private window or even after clearing your browser cache, it WON'T change.
4949
</code>
5050
<br>

client/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ async function bakeCookie(data) {
102102

103103
// Add SHA
104104
async function addSHA(sha) {
105-
const response = await fetch("https://mycookie-monster.herokuapp.com/add-sha/"+sha, {
105+
const response = await fetch("http://localhost:4000/add-sha/"+sha, {
106106
headers: {'Content-Type': 'application/json'},
107107
method: 'GET'
108108
})

index.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ const express = require('express');
22
var cors = require('cors');
33
var app = express();
44
const atob = require('atob');
5-
const KEY = require('./key');e
5+
const KEY = require('./key');
6+
const Base64 = require('base-64');
67

78
app.use(cors())
89

@@ -75,9 +76,19 @@ app.get('/generate/:data', async (req, res) => { // Because URL PARAMS ARE COOLE
7576
})
7677
})
7778

78-
app.get('/add-sha/:sha', async (req, res) => {
79-
console.log(req.params.sha)
80-
res.json({ "message": "Created" })
79+
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+
}, {
85+
headers: {'Authorization': "token " + KEY}
86+
}).then(res => {
87+
console.log(res.data)
88+
}).catch(e => {
89+
console.log(e)
90+
})
91+
return res.json({message: "Created"})
8192
})
8293

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

package-lock.json

Lines changed: 11 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"homepage": "https://github.com/ujjwal-kr/ip-sniff#readme",
2424
"dependencies": {
2525
"atob": "^2.1.2",
26-
"axios": "^0.21.0",
26+
"axios": "^0.21.1",
27+
"base-64": "^1.0.0",
2728
"body-parser": "^1.19.0",
2829
"cors": "^2.8.5",
2930
"express": "^4.17.1"

0 commit comments

Comments
 (0)