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.7.1 to 1.8.0

101

lib/routes.js

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

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

@@ -72,20 +73,20 @@ var routes = []

var pending = ops.length
ops.forEach(function (op) {
osm.batch(ops.map(function (op) {
var id
if (op.id) {
var id = op.id
id = op.id
delete op.id
osm.put(id, op, function (err) { oncreate(err, id) })
} else {
osm.create(op, oncreate)
id = hex2dec(randombytes(8).toString('hex'))
}
})
function oncreate (err, id) {
if (err) errors.push(err)
else ids.push(id)
return { type: 'put', key: id, value: op }
}), onbatch)
if (--pending === 0) {
res.setHeader('content-type', 'text/plain')
res.end(ids.join('\n'))
}
function onbatch (err, nodes) {
if (err) return error(500, res, err)
var ids = nodes.map(function (node) {
return node.value.k
})
res.setHeader('content-type', 'text/plain')
res.end(ids.join('\n'))
}

@@ -225,3 +226,3 @@ }

post('/api/0.6/changeset/:id/upload', function (req, res, osm, m) {
var errors = [], results = []
var results = []
var parts = m.params.id.split(':')

@@ -251,3 +252,3 @@ var version = parts.length === 2 ? parts[1] : null

var ops = xmldiff(body)
var pending = 1
var batch = [], onid = {}
ops.create.forEach(function (op) {

@@ -258,6 +259,9 @@ var id = op.id, oldId = op.oldId

delete op.version
pending++
osm.put(id, op, function (err, node) {
if (err) errors.push(err)
else results.push({
batch.push({
type: 'put',
key: id,
value: op
})
onid[id] = function (node) {
results.push({
type: op.type,

@@ -270,4 +274,3 @@ attr: {

})
if (--pending === 0) done()
})
}
})

@@ -282,6 +285,10 @@ ops.modify.forEach(function (op) {

delete op.version
pending++
osm.put(id, op, { links: links }, function (err, node) {
if (err) errors.push(err)
else results.push({
batch.push({
type: 'put',
key: id,
value: op,
links: links
})
onid[id] = function (node) {
results.push({
type: op.type,

@@ -294,4 +301,3 @@ attr: {

})
if (--pending === 0) done()
})
}
})

@@ -302,23 +308,28 @@ ops.delete.forEach(function (op) {

: undefined
pending++
osm.del(op.id, { links: links }, function (err) {
if (err) errors.push(err)
else results.push({
type: op.type,
attr: { old_id: op.oldId }
})
if (--pending === 0) done()
batch.push({
type: 'del',
id: op.id,
links: links
})
results.push({
type: op.type,
attr: { old_id: op.oldId }
})
})
if (--pending === 0) done()
}
function done () {
res.setHeader('content-type', 'text/xml')
res.end(h('diffResult',
{ generator: 'osm-p2p-server', version: '0.6' },
results.map(function (r) {
return h(r.type, r.attr)
osm.batch(batch, function (err, nodes) {
if (err) return error(500, res, err)
nodes.forEach(function (node) {
var id = node.value.k
if (onid.hasOwnProperty(id)) {
onid[id](node)
}
})
))
res.setHeader('content-type', 'text/xml')
res.end(h('diffResult',
{ generator: 'osm-p2p-server', version: '0.6' },
results.map(function (r) {
return h(r.type, r.attr)
})
))
})
}

@@ -325,0 +336,0 @@ })

{
"name": "osm-p2p-server",
"version": "1.7.1",
"version": "1.8.0",
"description": "serve osm http endpoints over a p2p db",

@@ -5,0 +5,0 @@ "main": "index.js",

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