Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

osm-p2p-server

Package Overview
Dependencies
Maintainers
2
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

osm-p2p-server - npm Package Compare versions

Comparing version 1.10.10 to 1.11.0

test/bbox_order.js

80

lib/routes.js

@@ -10,2 +10,3 @@ var h = require('./h.js')

var collect = require('collect-stream')
var once = require('once')
var hex2dec = require('./hex2dec.js')

@@ -349,3 +350,5 @@ var checkRefExist = require('./check_ref_ex.js')

})
var excheck = [], skip = {}
ops.delete.forEach(function (op) {
excheck.push(op)
var links = op.version !== undefined

@@ -364,3 +367,62 @@ ? (op.version || '').split(/\s*,\s*/).filter(Boolean)

})
osm.batch(batch, function (err, nodes) {
if (excheck.length === 0) return commit()
var cancel = false
var pending = excheck.length * 2 + 1
var exids = {}
excheck.forEach(function (op) {
exids[op.id] = op
})
excheck.forEach(function (op) {
osm.refs.list(op.id, function (err, refs) {
if (cancel) return
if (err) {
cancel = true
return error(500, res, err)
}
refs = refs.filter(function (ref) {
return !exids.hasOwnProperty(ref.value)
})
if (refs.length > 0 && op.ifUnused) {
skip[op.id] = true
} else if (refs.length > 0) {
cancel = true
getTypes(osm, refs, function (err, types) {
if (err) {
cancel = true
return error(500, res, err)
}
var msg = types.map(function (t,i) {
return 'Node #'+op.id+' is still used by '+t
+' #'+refs[i].value+'.'
}).join('\n')
return error(412, res, msg)
})
}
if (--pending === 0) commit()
})
osm.get(op.id, function (err, values) {
if (cancel) return
if (err) {
cancel = true
return error(500, res, err)
}
var len = Object.keys(values).length
if (len === 0 && op.ifUnused) {
skip[op.id] = true
} else if (len === 0) {
cancel = true
return error(404, res, 'Element not found: ' + op.id)
}
if (--pending === 0) commit()
})
})
if (--pending === 0) commit()
function commit () {
osm.batch(batch.filter(function (row) {
return !skip.hasOwnProperty(row.id)
}), onbatch)
}
function onbatch (err, nodes) {
if (err) return error(500, res, err)

@@ -380,3 +442,3 @@ nodes.forEach(function (node) {

))
})
}
}

@@ -448,1 +510,15 @@ })

}
function getTypes (osm, refs, cb) {
cb = once(cb)
var pending = 1 + refs.length
var types = []
refs.forEach(function (ref, i) {
osm.log.get(ref.key, function (err, doc) {
if (err) return cb(err)
types[i] = doc.value && doc.value.v && doc.value.v.type
if (--pending === 0) cb(null, types)
})
})
if (--pending === 0) cb(null, types)
}

@@ -46,2 +46,5 @@ var parsexml = require('xml-parser')

ops[c.name].push(doc)
if (c.name === 'delete' && c.attributes['if-unused'] !== undefined) {
doc.ifUnused = true
}
}

@@ -48,0 +51,0 @@ })

9

package.json
{
"name": "osm-p2p-server",
"version": "1.10.10",
"version": "1.11.0",
"description": "serve osm http endpoints over a p2p db",

@@ -24,2 +24,3 @@ "main": "index.js",

"minimist": "^1.2.0",
"once": "^1.3.3",
"osm-p2p-xml": "^1.0.1",

@@ -34,4 +35,8 @@ "randombytes": "^2.0.2",

"devDependencies": {
"fd-chunk-store": "^2.0.0",
"hyperlog": "^4.10.0",
"hyperquest": "^1.2.0",
"memdb": "^1.3.1",
"osm-p2p": "^1.1.0",
"hyperquest": "^1.2.0",
"osm-p2p-db": "^3.7.0",
"tape": "^4.4.0"

@@ -38,0 +43,0 @@ },

@@ -49,3 +49,3 @@ var test = require('tape')

var uploaded = {}
var SIZE = 1000
var SIZE = 100
test('add docs to changeset', function (t) {

@@ -146,5 +146,1 @@ t.plan(3)

})
function cmpch (a, b) {
return a.attributes.id < b.attributes.id ? -1 : 1
}

@@ -115,5 +115,1 @@ var test = require('tape')

})
function cmpch (a, b) {
return a.attributes.id < b.attributes.id ? -1 : 1
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc