|
|
@ -12,25 +12,10 @@ var nThen = require("nthen");
|
|
|
|
|
|
|
|
|
|
|
|
var config = require("./lib/load-config");
|
|
|
|
var config = require("./lib/load-config");
|
|
|
|
|
|
|
|
|
|
|
|
// This is stuff which will become available to replify
|
|
|
|
|
|
|
|
const debuggableStore = new WeakMap();
|
|
|
|
|
|
|
|
const debuggable = function (name, x) {
|
|
|
|
|
|
|
|
if (name in debuggableStore) {
|
|
|
|
|
|
|
|
try { throw new Error(); } catch (e) {
|
|
|
|
|
|
|
|
console.error('cannot add ' + name + ' more than once [' + e.stack + ']');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
debuggableStore[name] = x;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return x;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
debuggable('global', global);
|
|
|
|
|
|
|
|
debuggable('config', config);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// support multiple storage back ends
|
|
|
|
// support multiple storage back ends
|
|
|
|
var Storage = require(config.storage||'./storage/file');
|
|
|
|
var Storage = require(config.storage||'./storage/file');
|
|
|
|
|
|
|
|
|
|
|
|
var app = debuggable('app', Express());
|
|
|
|
var app = Express();
|
|
|
|
|
|
|
|
|
|
|
|
// mode can be FRESH (default), DEV, or PACKAGE
|
|
|
|
// mode can be FRESH (default), DEV, or PACKAGE
|
|
|
|
|
|
|
|
|
|
|
@ -275,7 +260,7 @@ var nt = nThen(function (w) {
|
|
|
|
if (typeof(config.rpc) !== 'string') { return; }
|
|
|
|
if (typeof(config.rpc) !== 'string') { return; }
|
|
|
|
// load pin store...
|
|
|
|
// load pin store...
|
|
|
|
var Rpc = require(config.rpc);
|
|
|
|
var Rpc = require(config.rpc);
|
|
|
|
Rpc.create(config, debuggable, w(function (e, _rpc) {
|
|
|
|
Rpc.create(config, w(function (e, _rpc) {
|
|
|
|
if (e) {
|
|
|
|
if (e) {
|
|
|
|
w.abort();
|
|
|
|
w.abort();
|
|
|
|
throw e;
|
|
|
|
throw e;
|
|
|
@ -298,7 +283,3 @@ var nt = nThen(function (w) {
|
|
|
|
var wsSrv = new WebSocketServer(wsConfig);
|
|
|
|
var wsSrv = new WebSocketServer(wsConfig);
|
|
|
|
NetfluxSrv.run(wsSrv, config, historyKeeper);
|
|
|
|
NetfluxSrv.run(wsSrv, config, historyKeeper);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (config.debugReplName) {
|
|
|
|
|
|
|
|
require('replify')({ name: config.debugReplName, app: debuggableStore });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|