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

osm-p2p-server

Package Overview
Dependencies
Maintainers
1
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.0.2 to 1.1.0

47

index.js

@@ -72,3 +72,3 @@ var routes = require('routes')

var docs = {}
params.changes.created.map(function (ch) {
params.changes.created.forEach(function (ch) {
docs[ch.id] = randombytes(8).toString('hex')

@@ -78,16 +78,3 @@ ch.id = docs[ch.id]

params.changes.created.forEach(function (ch) {
if (ch.loc) {
ch.lat = ch.loc[1]
ch.lon = ch.loc[0]
ch.type = 'node'
delete ch.loc
} else if (ch.nodes) {
ch.type = 'way'
ch.refs = ch.nodes.map(function (id) { return docs[id] })
delete ch.nodes
}
var id = ch.id
ch.timestamp = new Date().toISOString()
console.log('CREATE', ch)
delete ch.id
var id = fix(docs, ch)
pending++

@@ -100,2 +87,12 @@ self.osmdb.put(id, ch, function (err) {

})
params.changes.modified.forEach(function (ch) {
var id = fix(docs, ch)
pending++
var opts = { links: ch.version ? [ch.version] : [] }
self.osmdb.put(id, ch, opts, function (err) {
if (err) errors.push(err)
else keys.push(id)
if (--pending === 0) done()
})
})
if (--pending === 0) done()

@@ -113,2 +110,22 @@ })

function fix (docs, ch) {
if (ch.loc) {
ch.lat = ch.loc[1]
ch.lon = ch.loc[0]
ch.type = 'node'
delete ch.loc
} else if (ch.nodes) {
ch.type = 'way'
ch.refs = ch.nodes
.map(function (id) { return docs.hasOwnProperty(id) ? docs[id] : id })
.map(function (id) { return id.replace(/^[nw]/,'') })
delete ch.nodes
}
ch.timestamp = new Date().toISOString()
var id = ch.id
if (docs.hasOwnProperty(id)) id = docs[id]
delete ch.id
return id.replace(/^[nw]/, '')
}
function error (code, res, err) {

@@ -115,0 +132,0 @@ res.statusCode = code

{
"name": "osm-p2p-server",
"version": "1.0.2",
"version": "1.1.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