Repository navigation
Expand file tree
/
Copy pathindex.js
More file actions
61 lines (55 loc) · 1.66 KB
/
Copy pathindex.js
File metadata and controls
61 lines (55 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import axios from "axios";
import express from "express";
import crypto from "crypto";
const app = express();
const apiKey =
"dbe39902202c25ac81556135f5fc2d610c3522bc6ce5fc83f0ddc24ce2fe4d0a";
app.listen(process.env.PORT || 5000, () => console.log(`Listening on 5000`));
app.get("/", (req, res) => {
// res.send("hello world");
console.log(req.query.campaignId);
console.log(req.query.workerId);
console.log(req.query.slotId);
res.send(
`campaignID is ${req.query.campaignId} and workerID id ${req.query.workerId} and slitId is ${req.query.slotId}
<a href="/external?slotId=${req.query.slotId}" target="_blank">click here</a>
`
);
});
app.get("/external", async (req, res) => {
res.send(
`slot id is ${req.query.slotId} <a href="/getPayed?slotId=${req.query.slotId}" >get payed</a>`
);
});
app.get("/getPayed", async (req, res1) => {
const config = {
headers: {
MicroworkersApiKey: apiKey,
"Content-Type": "application/json",
},
};
await axios
.put(
`https://ttv-sandbox.microworkers.com/api/v2/slots/${req.query.slotId}/submitProof`,
{
answers: [
{
key: "paymentcode",
value: crypto.randomBytes(16).toString("hex"),
},
],
},
config
)
.then((res) => {
res1.send(`you got payed at ${req.query.slotId}`);
})
.catch((err) => {
res1.send(`you DID NOT get payed at ${req.query.slotId}`);
console.log(Object.getOwnPropertyNames(err));
// console.log(err.request);
// console.log("------------------------------------------");
// console.log(err.response);
console.log(err.message);
});
});