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
/* | |
Node works as expected: | |
node index.js # Prints help and exits with 1 status ('done' never printed) | |
node index.js parse # prints 'done', 0 status | |
Bare works fine with the parse command: | |
./node_modules/bare-runtime/bin/bare ./index.js # prints 'done', 0 status code | |
But fails on: | |
./node_modules/bare-runtime/bin/bare ./index.js |
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
import Hyperswarm from 'hyperswarm' | |
import Corestore from 'corestore' | |
import ram from 'random-access-memory' | |
/* | |
With hypercore 10.5.4, the output is: | |
origCore lenght: 1 | |
Replication with peer set up | |
Replication with peer set up | |
readCore length: 1 |
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 Corestore = require("corestore") | |
const ram = require("random-access-memory") | |
async function ensureIsNonExistingCoreName (name, corestore) { | |
try { | |
await (corestore.get({ name, createIfMissing: false })).ready() | |
} catch (e) { | |
return // Error confirms it is indeed missing | |
} | |
throw new Error(`A hypercore with name '${name}' already exists in the corestore`) |
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
// Tested on Hyperswarm V4, corestore V6, Hypercore V10 | |
// Server | |
const Hyperswarm = require('hyperswarm') | |
const Corestore = require("corestore") | |
const ram = require("random-access-memory") | |
async function runServer(){ | |
const corestore = new Corestore(ram) |
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
// Uses hypercore-next and hyperswarm V4 | |
// Server | |
const Hyperswarm = require('hyperswarm') | |
const Hypercore = require("hypercore") | |
const Hyperbee = require("hyperbee") | |
const ram = require("random-access-memory") | |
async function runServer(){ |
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
// See https://github.com/hypercore-protocol/hyperbee/issues/59 | |
// The server code creates a dht-relay and shares a hyperbee | |
// The client code loads a hyperbee through the relay | |
// The client code can be executed both from the browser and form Node | |
// SERVER (see below for CLIENT code) | |
const DHT = require("@hyperswarm/dht"); |
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 express = require('express') | |
var formidable = require('formidable') | |
util = require('util'); | |
const app = express() | |
const port = 3000 | |
app.listen(port, () => { | |
console.log(`Server listening at http://localhost:${port}`) |