osm-p2p-server
Advanced tools
Comparing version 1.10.4 to 1.10.5
@@ -47,3 +47,2 @@ var h = require('./h.js') | ||
put('/api/0.6/:type(node|way|relation|changeset)/create', function (req, res, osm, m) { | ||
var errors = [], ids = [] | ||
req.pipe(concat({ encoding: 'string' }, function (body) { | ||
@@ -103,3 +102,8 @@ if (/\/xml$/.test(req.headers['content-type'])) { | ||
if (err) return error(500, res, err) | ||
var docs = [], pending = ids.length | ||
var docs = [], pending = ids.length, errors = [] | ||
if (!ids.length) { | ||
res.setHeader('content-type', 'text/xml') | ||
res.end(render([])) | ||
return | ||
} | ||
ids.forEach(function (id) { | ||
@@ -110,2 +114,3 @@ osm.log.get(id, function (err, doc) { | ||
if (--pending === 0) { | ||
if (errors.length) return error(500, res, errors.join('\n')) | ||
res.setHeader('content-type', 'text/xml') | ||
@@ -112,0 +117,0 @@ res.end(render(docs)) |
{ | ||
"name": "osm-p2p-server", | ||
"version": "1.10.4", | ||
"version": "1.10.5", | ||
"description": "serve osm http endpoints over a p2p db", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
var test = require('tape') | ||
var request = require('http').request | ||
var tmpdir = require('os').tmpdir() | ||
@@ -11,3 +10,2 @@ var path = require('path') | ||
var concat = require('concat-stream') | ||
var parsexml = require('xml-parser') | ||
@@ -59,2 +57,15 @@ var base, server, changeId | ||
test('get empty osmchange doc', function (t) { | ||
t.plan(2) | ||
var href = base + 'changeset/' + changeId + '/download' | ||
var hq = hyperquest(href, { | ||
headers: { 'content-type': 'text/xml' } | ||
}) | ||
hq.pipe(concat({ encoding: 'string' }, function (body) { | ||
var xml = parsexml(body) | ||
t.equal(xml.root.name, 'osmChange') | ||
t.equal(xml.root.children.length, 0) | ||
})) | ||
}) | ||
var uploaded = {} | ||
@@ -61,0 +72,0 @@ test('add docs to changeset', function (t) { |
@@ -44,3 +44,4 @@ var test = require('tape') | ||
[ | ||
{ type: 'node', lat: 64.2, lon: -121.4, id: 'A' } | ||
{ type: 'node', lat: 64.2, lon: -121.4, id: 'A', | ||
tags: { beep: 'boop' } } | ||
], | ||
@@ -113,3 +114,6 @@ [ | ||
changeset="${changeId}" | ||
></node>` | ||
>${Object.keys(doc.tags || {}).map(function (key) { | ||
return `<tag k="${key}" v="${doc.tags[key]}"/>` | ||
}).join('')} | ||
</node>` | ||
} | ||
@@ -120,3 +124,6 @@ function modifyMap (doc) { | ||
changeset="${changeId}" | ||
></node>` | ||
>${Object.keys(doc.tags || {}).map(function (key) { | ||
return `<tag k="${key}" v="${doc.tags[key]}"/>` | ||
}).join('')} | ||
</node>` | ||
} | ||
@@ -150,3 +157,12 @@ function existFilter (doc) { return exists[doc.id] } | ||
}, | ||
children: [], | ||
children: [ | ||
{ | ||
name: 'tag', | ||
attributes: { | ||
k: 'beep', | ||
v: 'boop' | ||
}, | ||
children: [] | ||
} | ||
], | ||
content: '' | ||
@@ -153,0 +169,0 @@ }, |
74963
2348
18