gun/examples/express.js
Adriano Rogowski 680b2d115a AXE - peer/soul subscribe. In this version the peers receive only data subscribed with gun.get(...soul...).once(...)
TODO:
 1) if the peer change the id, will lost the subscribes. Workaround for this is set the pid (unique) in: Gun(pid: 'mypeerid', peers:[...])
 2) If the superpeer die, the subscribes will be lost. Each peer must resubscribe all souls.
2018-11-21 19:28:28 -02:00

18 lines
663 B
JavaScript

console.log("If module not found, install express globally `npm i express -g`!");
var port = process.env.OPENSHIFT_NODEJS_PORT || process.env.VCAP_APP_PORT || process.env.PORT || process.argv[2] || 8765;
var express = require('express');
var Gun = require('..');
require('../axe');
var app = express();
app.use(Gun.serve);
app.use(express.static(__dirname));
var server = app.listen(port);
var gun = Gun({ file: 'data', web: server });
global.Gun = Gun; /// make global to `node --inspect` - debug only
global.gun = gun; /// make global to `node --inspect` - debug only
console.log('Server started on port ' + port + ' with /gun');