Skip to content

Repository files navigation

gun.js peer

Cloudflare Workers Gun.js-compatible peer with a stats dashboard and persistent Durable Object storage.

local

npm install
npm run dev

Dashboard at the Wrangler dev URL, usually http://localhost:8787. Gun clients should use the /gun peer endpoint:

const gun = Gun({
  peers: ["https://your-worker.example.com/gun"],
});

build

npm run build

deploy

npm run deploy

endpoints

  • / - dashboard
  • /gun - Gun-compatible WebSocket peer endpoint
  • /api/stats - dashboard stats
  • /api/peers - mesh peer list (GET public, POST/DELETE need PEERS_EDIT_TOKEN when set)
  • /api/peers/verify - probe a gun peer url (POST, no auth)
  • /api/peers/reconnect - force server-side mesh reconnect (POST, same auth as peer edits)
  • /api/graph/souls - node index (limit, cursor, prefix, q, sort=updated)
  • /api/graph/node - structured node inspector (soul)
  • /api/graph/subgraph - nodes + reference edges for the explorer (roots, prefix, depth, maxNodes)
  • /explorer.html - graph explorer UI
  • /health - health check

persistence

The old Node server used Gun Radisk with file: "data". Cloudflare Workers do not provide a persistent local filesystem for that model, so this version stores Gun graph nodes in Durable Object storage instead. Each write is acknowledged after the graph merge is stored, and reads are served from the Durable Object.

About

gun.js peer server with stats dashboard

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages