Use process.stdout.write instead of console.log to avoid newline
Add setup.js for keypair creation
Use parseArgs polyfill to support Node versions other than 16 and 18
Example Node.js project for syncing to and from Hyperdrives with Hyper-SDK@4
This example uses Hyperdrive to send p2p files over the Hyperswarm network using Hyper-SDK and the Mirror-Drive API.
push.js
takes a folder path (or the current working directory) and uploads data (except for things starting with .
or node_modules/
) into an in-memory Hyperdrive.
It then starts advertising the hyperdrive's data on hyperswarm via the hyperdrive's discovery key.
It also prints the hyper://
URL of the hyperdrive.
Then, other users may use pull.js
with the URL of the hyperdrive (and an optional folder path) to pull changes from the drive to their local computer.
You can see your swarm ID and the incoming / disconnecting peers as the sync takes place.
Note that this example doesn't persist data locally, and it's up to you to figure out how to manage storage if you're making more complex APIs.
For an easy to use service for publishing to hyperdrive, check out Distributed Press.
./push.js ./my_folder
./pull.js hyper://blog.mauve.moe ./my_other_folder