BlockHub Node Operator assists BlockHub clients with the following:
- Brokering p2p connections between clients. Data is not proxied/passed through the operator.
- Distributing IPFS downloads.
- Serving data for clients to hydrate screen information (such as a product page).
- 🌐 Site - Production
- 📺 Site - Preview
- 📺 Site - Beta
- 📺 Site - Staging
- 📖 Docs
- 📓 EIPs
- 💻 Web Client
- 💻 Desktop Client
- 🛡 Node Operator
- 🔗 Protocol
Install Node Package Manager (NVM):
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
Install Node 8.11.1:
nvm install 8.11.1
If you get nvm: command not found
, simply close your current terminal, open a new terminal, and try again. Please see the NVM readme if you have any issues.
Install the library:
$> yarn add blockhub-node-operator
Run the server:
$> blockhub-node-operator --port 9000 --key nodeOperator
Or, create a custom server:
let BlockHubServer = require('blockhub-node-operator').BlockHubServer
let server = BlockHubServer({ port: 9000, path: '/myapp' })
Connecting to the server from frontend:
<script>
let peer = new Peer('someid', { host: 'localhost', port: 9000, path: '/myapp' })
</script>
Using HTTPS: Simply pass in PEM-encoded certificate and key.
let fs = require('fs')
let BlockHubServer = require('peer').BlockHubServer
let server = BlockHubServer({
port: 9000,
ssl: {
key: fs.readFileSync('/path/to/your/ssl/key/here.key'),
cert: fs.readFileSync('/path/to/your/ssl/certificate/here.crt')
}
})
Make sure to set the proxied
option, otherwise IP based limiting will fail.
The option is passed verbatim to the
expressjs trust proxy
setting
if it is truthy.
let BlockHubServer = require('blockhub-node-operator').BlockHubServer
let server = BlockHubServer({ port: 9000, path: '/myapp', proxied: true })
let express = require('express')
let app = express()
let ExpressServer = require('blockhub-node-operator').ExpressServer
app.get('/', function(req, res, next) { res.send('Hello world!') })
// =======
let server = app.listen(9000)
let options = {
debug: true
}
let expressServer = ExpressServer(server, options)
app.use('/api', expressServer)
// == OR ==
let server = require('http').createServer(app)
let expressServer = ExpressServer(server, options)
app.use('/nodeOperator', expressServer)
server.listen(9000)
// ========
The 'connection'
event is emitted when a peer connects to the server.
expressServer.on('connection', function(id) { ... })
The 'disconnect'
event is emitted when a peer disconnects from the server or
when the peer can no longer be reached.
expressServer.on('disconnect', function(id) { ... })
Discuss Node Operator on our Gitter: https://gitter.im/Hyperbridge/Lobby
Please post any bugs as a Github issue.