-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
30 lines (24 loc) · 809 Bytes
/
index.js
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
require("dotenv").config();
const { setTimeout } = require("timers/promises");
const { publish, get } = require("./src/apis/OTNode");
const apis = require("./src/util/apis");
const logPrettyJSON = (data) => console.log(JSON.stringify(data, null, 2));
(async () => {
while (true) {
for (const api of apis) {
console.log(`About to publish dataset taken from ${api.name}`);
// fetch data
const data = await api.getData();
// create asset
const publishResult = await publish(data);
logPrettyJSON(publishResult)
// get asset
if (publishResult?.operation?.status === "COMPLETED") {
const getResult = await get(publishResult.UAL);
logPrettyJSON(getResult);
}
// sleep 5 seconds
await setTimeout(5 * 1000);
}
}
})();