- Notifications
You must be signed in to change notification settings - Fork4
QXIP/gun-host
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
It is a lib to runGun host in Node.js
npm install --save https://github.com/QXIP/gun-host
The example illustrates creating cluster nodesentinl
, adding a child nodehosts
, then addingconfig.host
node as a child ofhosts
.
const GunHost = require('gun-host');const config = { enabled: true, name: 'sentinl', priority_for_master: 0, absent_time_for_delete: 86400, absent_time: 15, loop_delay: 5, cert: { selfsigned: true, valid: 10, key: null, // full sys path to pem key file cert: null, // full sys path to cert file }, gun: { port: 9000, host: '0.0.0.0', cache: 'data.json', peers: ['https://localhost:9000/gun'], }, host: { id: '123', name: 'velociraptor', priority: 0, node: 'hosts', },};const node = new GunHost({ peers: config.gun.peers, rootNodeName: config.name,});const main = async function() { try { let resp = await node.start({ host: config.gun.host, port: config.gun.port, cache: config.gun.cache, cert: config.cert, }); console.log('1. Start server:', resp); resp = await node.add(`${config.host.node}.${config.host.id}`, config.host); console.log('2. Add node:', resp); resp = await node.get(config.host.node); console.log('3. Get node:', resp); } catch (err) { console.error(err); }};main();
Gun holds
root: { senitnl: {}}
const addData = async function() { try { resp = await node.add(`${config.host.node}.${config.host.id}`, config.host); console.log('2. Add node:', resp); resp = await node.get(config.host.node); console.log('3. Get node:', resp); } catch (err) { console.error(err); }};addData();
Gun holds
root: { setninl: { hosts: { '123': { id: '123', name: 'velociraptor', priority: 0, node: 'hosts', } } }}
const delete = async function() { try { resp = await node.delete(`${config.host.node}.${config.host.id}`); console.log('4. Delete node:', resp); resp = await node.get(config.host.node); console.log('5. Check if node exists after removing', resp); } catch (err) { console.error(err); }};delete();
Gun holds
root: { setninl: { hosts: {} }}
npm install -g eslint eslint-config-google nyc
npm run rest
node examples/usage.js
About
GunDB HTTP/HTTPS Server and API
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.