Created
August 20, 2015 06:54
-
-
Save next-marianmoldovan/aefa29b8d81a9ded3c0b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var th = require("telehash"); | |
function startMesh(keys){ | |
th.mesh({id:keys}, function(err, mesh){ | |
if(err) return console.log("mesh failed to initialize",err); | |
// use mesh.* now | |
console.log(mesh.uri()); | |
}); | |
} | |
var FileStore = require("file-store") | |
, store = FileStore("data.json"); | |
store.get("keys", function (err, value) { | |
if(!value) { | |
th.generate(function(err, endpoint){ | |
if(err) return console.log("endpoint generation failed",err); | |
else { | |
store.set('keys', endpoint); | |
console.log('Keys created and saved...'); | |
} | |
}); | |
} | |
else { | |
startMesh(value); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment