Skip to content

Instantly share code, notes, and snippets.

@draeder
Created May 30, 2022 14:35
Show Gist options
  • Save draeder/1af1da351299a25c9f63bb4fae90c1db to your computer and use it in GitHub Desktop.
Save draeder/1af1da351299a25c9f63bb4fae90c1db to your computer and use it in GitHub Desktop.
Gun server example
const http = require('http')
const Gun = require('gun')
// Uncomment for ES6, and remove requires above
// import http from 'http'
// import Gun from 'gun'
const server = http.createServer()
const host = 'localhost'
const port = 8080
var gun = Gun({
web: server,
peers: ['https://relay.peer.ooo/gun']
})
server.listen(8080, () => {
console.log(
'Server started on port ' + port + ' with /gun',
)
gun.get('test').on(data => console.log(data))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment