How to use the gun.serve function in gun

To help you get started, we’ve selected a few gun examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github irislib / iris-lib / src / util.js View on Github external
const newGuns = ports.map(port => {
      const server = http.createServer(Gun.serve).listen(port, ip);
      const g = new Gun({
        radisk: false,
        port: port,
        multicast: false,
        peers: {},
        // file: `${configDir}/${gunDBName}.${port}`,
        web: server,
      });
      g.netPort = port;
      g.netId = netId;
      return g;
    });
github zrrrzzt / gun-restrict-examples / gun-servers / server-gun-restricted-put.js View on Github external
const server = require('http').createServer((req, res) => {
  // filters gun requests!
  if (Gun.serve(req, res)) {
    return
  }
  require('fs').createReadStream(require('path').join(__dirname, req.url)).on('error', function () {
    res.writeHead(200, { 'Content-Type': 'text/html' })
    res.end(require('fs')
      .readFileSync(require('path')
        .join(__dirname, 'index.html')
      ))
  }).pipe(res)
})
github zrrrzzt / gun-restrict-examples / gun-servers / server-gun-unrestricted.js View on Github external
const server = require('http').createServer((req, res) => {
  // filters gun requests!
  if (Gun.serve(req, res)) {
    return
  }
  require('fs').createReadStream(require('path').join(__dirname, req.url)).on('error', function () {
    res.writeHead(200, { 'Content-Type': 'text/html' })
    res.end(require('fs')
      .readFileSync(require('path')
        .join(__dirname, 'index.html')
      ))
  }).pipe(res)
})
github zrrrzzt / gun-restrict-examples / gun-servers / server-gun-restricted.js View on Github external
const server = require('http').createServer((req, res) => {
  // filters gun requests!
  if (Gun.serve(req, res)) {
    return
  }
  require('fs').createReadStream(require('path').join(__dirname, req.url)).on('error', function () {
    res.writeHead(200, {'Content-Type': 'text/html'})
    res.end(require('fs')
    .readFileSync(require('path')
    .join(__dirname, 'index.html')
  ))
  }).pipe(res)
})
github DaoCasino / BankRollerApp / src / server.electron.js View on Github external
const server = http.createServer(function (request, response) {
	if(Gun.serve(request, response)){
		return
	}

	response.setHeader('Access-Control-Allow-Origin', '*')

	if (DApps.serve(request, response)) {
		return
	}


	let filePath = __dirname + request.url
	if (filePath == __dirname+'/'){
		filePath = __dirname+'/index.html'
	}

	// Static serve
github DaoCasino / BankRollerApp / public / server.electron.js View on Github external
let server = http.createServer(function (request, response) {
	if(Gun.serve(request, response)){
		return
	}

	let filePath = __dirname + request.url
	if (filePath == __dirname+'/'){
		filePath = __dirname+'/index.html'
	}

	let contentType = filetypes[path.extname(filePath)] || false

	fs.readFile(filePath, function(error, content) {
		if (error) {
			if(error.code == 'ENOENT'){
				fs.readFile(__dirname+'/index.html', function(error, content) {
					if (contentType) {
						response.writeHead(200, { 'Content-Type': contentType })

gun

A realtime, decentralized, offline-first, graph data synchronization engine.

(Zlib OR MIT OR Apache-2.0)
Latest version published 19 days ago

Package Health Score

83 / 100
Full package analysis