{"id":19952650,"url":"https://github.com/qxip/gun-host","last_synced_at":"2025-05-03T19:30:51.346Z","repository":{"id":57259669,"uuid":"118450099","full_name":"QXIP/gun-host","owner":"QXIP","description":"GunDB HTTP/HTTPS Server and API","archived":false,"fork":false,"pushed_at":"2018-02-15T16:23:30.000Z","size":7110,"stargazers_count":18,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-17T11:19:43.428Z","etag":null,"topics":["api","gun","gundb","server"],"latest_commit_sha":null,"homepage":"http://qxip.net","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/QXIP.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-22T11:46:23.000Z","updated_at":"2024-10-21T13:45:18.000Z","dependencies_parsed_at":"2022-08-24T21:51:35.341Z","dependency_job_id":null,"html_url":"https://github.com/QXIP/gun-host","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QXIP%2Fgun-host","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QXIP%2Fgun-host/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QXIP%2Fgun-host/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QXIP%2Fgun-host/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/QXIP","download_url":"https://codeload.github.com/QXIP/gun-host/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252241942,"owners_count":21717073,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","gun","gundb","server"],"created_at":"2024-11-13T01:13:59.026Z","updated_at":"2025-05-03T19:30:50.953Z","avatar_url":"https://github.com/QXIP.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gun-host\nIt is a lib to run [Gun](http://gun.js.org) host in Node.js\n\n1. [Install](#install)\n2. [Usage](#usage)\n3. [Development](#development)\n\n# Install\n```\nnpm install --save https://github.com/QXIP/gun-host\n```\n\n# Usage\nThe example illustrates creating cluster node `sentinl`, adding a child node `hosts`, then adding `config.host` node as a child of `hosts`.\n\n## Init and start host\n```\nconst GunHost = require('gun-host');\n\nconst config = {\n  enabled: true,\n  name: 'sentinl',\n  priority_for_master: 0,\n  absent_time_for_delete: 86400,\n  absent_time: 15,\n  loop_delay: 5,\n  cert: {\n    selfsigned: true,\n    valid: 10,\n    key: null, // full sys path to pem key file\n    cert: null, // full sys path to cert file\n  },\n  gun: {\n    port: 9000,\n    host: '0.0.0.0',\n    cache: 'data.json',\n    peers: ['https://localhost:9000/gun'],\n  },\n  host: {\n    id: '123',\n    name: 'velociraptor',\n    priority: 0,\n    node: 'hosts',\n  },\n};\n\nconst node = new GunHost({\n  peers: config.gun.peers,\n  rootNodeName: config.name,\n});\n\nconst main = async function() {\n  try {\n    let resp = await node.start({\n      host: config.gun.host,\n      port: config.gun.port,\n      cache: config.gun.cache,\n      cert: config.cert,\n    });\n    console.log('1. Start server:', resp);\n\n    resp = await node.add(`${config.host.node}.${config.host.id}`, config.host);\n    console.log('2. Add node:', resp);\n\n    resp = await node.get(config.host.node);\n    console.log('3. Get node:', resp);\n  } catch (err) {\n    console.error(err);\n  }\n};\n\nmain();\n```\nGun holds\n```\nroot: {\n  senitnl: {}\n}\n\n```\n## Add/get data\n```\nconst addData = async function() {\n  try {\n    resp = await node.add(`${config.host.node}.${config.host.id}`, config.host);\n    console.log('2. Add node:', resp);\n\n    resp = await node.get(config.host.node);\n    console.log('3. Get node:', resp);\n  } catch (err) {\n    console.error(err);\n  }\n};\n\naddData();\n```\nGun holds\n```\nroot: {\n  setninl: {\n    hosts: {\n      '123': {\n        id: '123',\n        name: 'velociraptor',\n        priority: 0,\n        node: 'hosts',\n      }\n    }\n  }\n}\n```\n## Delete data\n```\nconst delete = async function() {\n  try {\n    resp = await node.delete(`${config.host.node}.${config.host.id}`);\n    console.log('4. Delete node:', resp);\n\n    resp = await node.get(config.host.node);\n    console.log('5. Check if node exists after removing', resp);\n  } catch (err) {\n    console.error(err);\n  }\n};\n\ndelete();\n```\nGun holds\n```\nroot: {\n  setninl: {\n    hosts: {}\n  }\n}\n```\n# Development\n## Install libs\n```\nnpm install -g eslint eslint-config-google nyc \n```\n## Test\n```\nnpm run rest\n```\n## Run examples\n```\nnode examples/usage.js\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqxip%2Fgun-host","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqxip%2Fgun-host","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqxip%2Fgun-host/lists"}