Created
December 6, 2020 18:02
-
-
Save anotherjesse/1e9280321229836e68e40f39c6c51878 to your computer and use it in GitHub Desktop.
gets list of files in /sync folder of hyperdrive, files that are 64 chars are added to dat-store
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
const { exec } = require("child_process"); | |
const util = require('util'); | |
// const primary = '64 character key here' | |
const adder = (url) => { | |
exec(`node bin.js add ${url}`) | |
} | |
const query = () => { | |
http.get(`http://localhost:3472/gateway/${primary}/sync/`, (response) => { | |
let body = ''; | |
response.on('data', (chunk) => { | |
body += chunk; | |
}); | |
// called when the complete response is received. | |
response.on('end', () => { | |
const urls = body.match(/href="\w{64}"/g).map(m => m.split('"')[1]); | |
console.log(`found ${urls.length} hyperdrives`) | |
urls.forEach(adder); | |
}); | |
}) | |
} | |
setInterval(query, 60000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment