Skip to content

Commit 936ebcb

Browse files
Merge pull request #7 from joaquimserafim/v3.0.0
V3
2 parents 753b7cb + 98586e4 commit 936ebcb

File tree

6 files changed

+4238
-103
lines changed

6 files changed

+4238
-103
lines changed

Diff for: .travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
language: node_js
22
node_js:
33
- 6
4+
- 8
5+
- 10
46
branches:
57
only:
68
- master

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ API v0.6 is the current version of the OSM Editing API deployed 17-21 April 2009
3131
- url, string, OpenStreetMap URL, default to `nominatim.openstreetmap.org`
3232
- port, integer, OpenStreetMap port, default to `80`
3333
- timeout, integer, client timeout, default to `10000` mls
34+
- userAgent, string, OpenStreetMap needs to receive this header, default to node-open-geocoder
3435

3536
#### geocode
3637

Diff for: index.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ max-len: ["error", 80]
66
*/
77
'use strict'
88

9-
const http = require('http')
9+
const https = require('https')
1010
const parse = require('json-parse-safe')
1111
const isValidCoordinates = require('is-valid-coordinates')
1212
const isObject = require('is.object')
@@ -20,8 +20,11 @@ class Geocoder {
2020
this.httpOptions = {
2121
hostname: getPropValue(options, 'url') || 'nominatim.openstreetmap.org',
2222
basePath: getPropValue(options, 'basePath') || '',
23-
port: getPropValue(options, 'port') || 80,
24-
agent: false
23+
port: getPropValue(options, 'port') || 443,
24+
agent: false,
25+
headers: {
26+
'User-Agent': getPropValue(options, 'userAgent') || 'node-open-geocoder'
27+
}
2528
}
2629
this.timeout = getPropValue(options, 'timeout') || 10000
2730
}
@@ -53,15 +56,10 @@ class Geocoder {
5356
}
5457

5558
end (cb) {
56-
// I put http here since you're using the http module.
57-
const req = http.get('http://' +
58-
this.httpOptions.hostname + ':' +
59-
this.httpOptions.port +
60-
this.httpOptions.basePath +
61-
this.httpOptions.path,
62-
responseHandler.bind(this, cb))
59+
const req = https.get(this.httpOptions, responseHandler.bind(this, cb))
6360

6461
req.setTimeout(this.timeout, timeoutCb)
62+
6563
req.once('error', onError)
6664

6765
function timeoutCb () {

0 commit comments

Comments
 (0)