Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
});
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)
})
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)
})
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)
})
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
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 })