Skip to content

Instantly share code, notes, and snippets.

@anotherjesse
Created December 6, 2020 18:02
Show Gist options
  • Save anotherjesse/1e9280321229836e68e40f39c6c51878 to your computer and use it in GitHub Desktop.
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
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