diff --git a/.jshintrc b/.jshintrc index ba6d0c2..0d8d561 100644 --- a/.jshintrc +++ b/.jshintrc @@ -4,5 +4,5 @@ "node": true, "loopfunc": true, "expr": true, - "esversion": 6 + "esversion": 11 } diff --git a/README.md b/README.md index ce0fee4..8b5a8bc 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ geocoder.init( ); ``` -Optionally `init()` allows you to specify the directory that geonames files are +Optionally `init()` allows you to specify the directory that GeoNames files are downloaded and cached in, and a specific cities database to be used. ```javascript @@ -330,9 +330,9 @@ of disk space). All follow-up requests are lightning fast. ### Downloading specific sets of countries To reduce the time taken to initialize the data, you can manually configure it -to only download a specific set of countries from Geonames. Do note that when +to only download a specific set of countries from GeoNames. Do note that when you add a country code into the array, it will disable the geocoder from -downloading all ~2GB(!) worth of data and only load the specified countries' +downloading all ~2.29GB(!) worth of data and only load the specified countries' data. If you want to re-enable the geocoder to download all data, the countries array needs to be empty. @@ -359,10 +359,10 @@ geocoder.init( ### Post-install script -There's also the option of downloading the Geonames files via a post-install -script. +There's also the option of downloading the GeoNames files via a post-install +script. The script is invoked automatically after installation, but won't download any -files without getting at least one of the init options in an env variable. +files without getting at least one of the init options in an env variable. The options should be specified with a `GEOCODER_POSTINSTALL_` prefix. #### Example of downloading the files via the post-install script @@ -417,8 +417,8 @@ specific language governing permissions and limitations under the License. ## Acknowledgements This project was inspired by Richard Penman's Python -[reverse geocoder](https://github.com/richardpenman/reverse_geocode/). It -uses Ubilabs' +[reverse geocoder](https://github.com/richardpenman/reverse_geocode/). It uses +Ubilabs' [k-d-tree implementation](https://github.com/ubilabs/kd-tree-javascript) that was ported to Node.js by [Luke Arduini](https://github.com/luk-/node-kdt). diff --git a/app.js b/app.js index 568cb73..b56b412 100644 --- a/app.js +++ b/app.js @@ -55,7 +55,7 @@ app.listen(port, function () { console.log('Local reverse geocoder listening on port ' + port); console.log('Initializing Geocoder…'); console.log( - '(This may take a long time and will download ~300MB worth of data.)' + '(This may take a long time and will download ~2.29GB worth of data by default.)' ); geocoder.init( { diff --git a/app.ts b/app.ts index e88ae1d..7a3dfc7 100644 --- a/app.ts +++ b/app.ts @@ -67,7 +67,7 @@ app.listen(port, function () { console.log('Local reverse geocoder listening on port ' + port); console.log('Initializing Geocoder…'); console.log( - '(This may take a long time and will download ~300MB worth of data.)' + '(This may take a long time and will download ~2.29GB worth of data by default.)' ); geocoder.init( diff --git a/docs/global.html b/docs/global.html index 08a1d15..04448a3 100644 --- a/docs/global.html +++ b/docs/global.html @@ -169,7 +169,8 @@
Parameters:
- One single or an array of latitude/longitude pairs + One single or an array of + latitude/longitude pairs @@ -296,7 +297,20 @@
Returns:
Example
-
// With just one point
var point = {latitude: 42.083333, longitude: 3.1};
geocoder.lookUp(point, 1, function(err, res) {
  console.log(JSON.stringify(res, null, 2));
});

// In batch mode with many points
var points = [
  {latitude: 42.083333, longitude: 3.1},
  {latitude: 48.466667, longitude: 9.133333}
];
geocoder.lookUp(points, 1, function(err, res) {
  console.log(JSON.stringify(res, null, 2));
});
+
// With just one point
+var point = {latitude: 42.083333, longitude: 3.1};
+geocoder.lookUp(point, 1, function(err, res) {
+  console.log(JSON.stringify(res, null, 2));
+});
+
+// In batch mode with many points
+var points = [
+  {latitude: 42.083333, longitude: 3.1},
+  {latitude: 48.466667, longitude: 9.133333}
+];
+geocoder.lookUp(points, 1, function(err, res) {
+  console.log(JSON.stringify(res, null, 2));
+});
@@ -320,7 +334,7 @@

Home

Global


diff --git a/docs/index.html b/docs/index.html index 29c2478..8d98c3e 100644 --- a/docs/index.html +++ b/docs/index.html @@ -56,7 +56,7 @@

Home

Global


diff --git a/docs/index.js.html b/docs/index.js.html index ca62e5d..d641950 100644 --- a/docs/index.js.html +++ b/docs/index.js.html @@ -59,16 +59,16 @@

Source: index.js

var debug = require('debug')('local-reverse-geocoder'); var fs = require('fs'); -var path = require('path'); var parser = require('csv-parse'); var parse = parser.parse; var kdTree = require('kdt'); -var fetch = (...args) => - import('node-fetch').then(({ default: fetch }) => fetch(...args)); var unzip = require('unzip-stream'); var async = require('async'); var readline = require('readline'); const { basename } = require('path'); +// mod.cjs +const fetch = (...args) => + import('node-fetch').then(({ default: fetch }) => fetch(...args)); // All data from http://download.geonames.org/export/dump/ var GEONAMES_URL = 'https://download.geonames.org/export/dump/'; @@ -169,7 +169,7 @@

Source: index.js

downloadMethodBoundToThis, callback ) { - const now = new Date().toISOString().substr(0, 10); + const now = new Date().toISOString().substring(0, 10); // Use timestamped file OR bare file const timestampedBasename = `${baseName}_${now}.txt`; @@ -222,7 +222,7 @@

Source: index.js

.then((response) => { if (!response.ok) { throw new Error( - `Error downloading GeoNames ${dataName} data (response ${response.status} for url ${geonamesUrl})` + `Error downloading GeoNames ${dataName} data (response ${response.status} for URL ${geonamesUrl})` ); } @@ -270,7 +270,7 @@

Source: index.js

.then((response) => { if (!response.ok) { throw new Error( - `Error downloading GeoNames ${dataName} data (response ${response.status} for url ${geonamesUrl})` + `Error downloading GeoNames ${dataName} data (response ${response.status} for URL ${geonamesUrl})` ); } @@ -285,7 +285,7 @@

Source: index.js

.on('entry', (entry) => { var entryPath = entry.path; var entryType = entry.type; // 'Directory' or 'File' - var entrySize = entry.size; // might be undefined in some archives + var entrySize = entry.size; // Might be undefined in some archives if (entryType === 'File' && entryPath === fileNameInsideZip) { debug( `Unzipping GeoNames ${dataName} data - found ${entryType} ${entryPath}` + @@ -311,13 +311,12 @@

Source: index.js

} }) .on('finish', () => { - // beware - this event is a finish of unzip, finish event of writeStream may and will happen later ... + // Beware - this event is a finish of unzip, finish event of writeStream may and will happen later... if (foundFiles === 1) { - // ... so if we found one file, we call callback in it's finish event above + // ...so if we found one file, we call callback in it's finish event above debug(`Unzipped GeoNames ${dataName} data.`); - // return callback(null, outputFilePath); } else { - // .. while if there is something unexpected, we fire callback here + // ...while if there is something unexpected, we fire callback here debug( `Error unzipping ${geonamesZipFilename}: Was expecting ${outputFileName}, found ${foundFiles} file(s).` ); @@ -989,7 +988,7 @@

Home

Global


diff --git a/index.js b/index.js index 531e979..28217c0 100755 --- a/index.js +++ b/index.js @@ -31,15 +31,16 @@ var debug = require('debug')('local-reverse-geocoder'); var fs = require('fs'); -var path = require('path'); var parser = require('csv-parse'); var parse = parser.parse; var kdTree = require('kdt'); -var fetch = require('node-fetch'); var unzip = require('unzip-stream'); var async = require('async'); var readline = require('readline'); const { basename } = require('path'); +// mod.cjs +const fetch = (...args) => + import('node-fetch').then(({ default: fetch }) => fetch(...args)); // All data from http://download.geonames.org/export/dump/ var GEONAMES_URL = 'https://download.geonames.org/export/dump/'; @@ -140,7 +141,7 @@ var geocoder = { downloadMethodBoundToThis, callback ) { - const now = new Date().toISOString().substr(0, 10); + const now = new Date().toISOString().substring(0, 10); // Use timestamped file OR bare file const timestampedBasename = `${baseName}_${now}.txt`; @@ -193,7 +194,7 @@ var geocoder = { .then((response) => { if (!response.ok) { throw new Error( - `Error downloading GeoNames ${dataName} data (response ${response.status} for url ${geonamesUrl})` + `Error downloading GeoNames ${dataName} data (response ${response.status} for URL ${geonamesUrl})` ); } @@ -241,7 +242,7 @@ var geocoder = { .then((response) => { if (!response.ok) { throw new Error( - `Error downloading GeoNames ${dataName} data (response ${response.status} for url ${geonamesUrl})` + `Error downloading GeoNames ${dataName} data (response ${response.status} for URL ${geonamesUrl})` ); } @@ -256,7 +257,7 @@ var geocoder = { .on('entry', (entry) => { var entryPath = entry.path; var entryType = entry.type; // 'Directory' or 'File' - var entrySize = entry.size; // might be undefined in some archives + var entrySize = entry.size; // Might be undefined in some archives if (entryType === 'File' && entryPath === fileNameInsideZip) { debug( `Unzipping GeoNames ${dataName} data - found ${entryType} ${entryPath}` + @@ -282,13 +283,12 @@ var geocoder = { } }) .on('finish', () => { - // beware - this event is a finish of unzip, finish event of writeStream may and will happen later ... + // Beware - this event is a finish of unzip, finish event of writeStream may and will happen later... if (foundFiles === 1) { - // ... so if we found one file, we call callback in it's finish event above + // ...so if we found one file, we call callback in it's finish event above debug(`Unzipped GeoNames ${dataName} data.`); - // return callback(null, outputFilePath); } else { - // .. while if there is something unexpected, we fire callback here + // ...while if there is something unexpected, we fire callback here debug( `Error unzipping ${geonamesZipFilename}: Was expecting ${outputFileName}, found ${foundFiles} file(s).` ); diff --git a/package-lock.json b/package-lock.json index 480a573..6d902cc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "local-reverse-geocoder", - "version": "0.16.2", + "version": "0.16.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "local-reverse-geocoder", - "version": "0.16.2", + "version": "0.16.3", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { @@ -14,13 +14,13 @@ "csv-parse": "^5.4.0", "debug": "^4.3.4", "kdt": "^0.1.0", - "node-fetch": "^2.6.11", + "node-fetch": "^3.3.1", "unzip-stream": "^0.3.1" }, "devDependencies": { "@types/cors": "^2.8.13", "@types/express": "^4.17.17", - "@types/node": "^20.2.5", + "@types/node": "^20.3.0", "cors": "^2.8.5", "express": "^4.18.2", "jsdoc": "^4.0.2", @@ -136,9 +136,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.2.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.2.5.tgz", - "integrity": "sha512-JJulVEQXmiY9Px5axXHeYGLSjhkZEnD+MDPDGbCbIAbMslkKwmygtZFy1X6s/075Yo94sf8GuSlFfPzysQrWZQ==", + "version": "20.3.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.3.0.tgz", + "integrity": "sha512-cumHmIAf6On83X7yP+LrsEyUOf/YlociZelmpRYaGFydoaPdxdt80MAbu6vWerQT2COCp2nPvHdsbD7tHn/YlQ==", "dev": true }, "node_modules/@types/qs": { @@ -407,6 +407,14 @@ "resolved": "https://registry.npmjs.org/csv-parse/-/csv-parse-5.4.0.tgz", "integrity": "sha512-JiQosUWiOFgp4hQn0an+SBoV9IKdqzhROM0iiN4LB7UpfJBlsSJlWl9nq4zGgxgMAzHJ6V4t29VAVD+3+2NJAg==" }, + "node_modules/data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "engines": { + "node": ">= 12" + } + }, "node_modules/date-now": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", @@ -603,6 +611,28 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, + "node_modules/fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "paypal", + "url": "https://paypal.me/jimmywarting" + } + ], + "dependencies": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + }, + "engines": { + "node": "^12.20 || >= 14.13" + } + }, "node_modules/finalhandler": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", @@ -636,6 +666,17 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, + "node_modules/formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "dependencies": { + "fetch-blob": "^3.1.2" + }, + "engines": { + "node": ">=12.20.0" + } + }, "node_modules/forwarded": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", @@ -1069,23 +1110,39 @@ "node": ">= 0.6" } }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "engines": { + "node": ">=10.5.0" + } + }, "node_modules/node-fetch": { - "version": "2.6.11", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.11.tgz", - "integrity": "sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w==", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.1.tgz", + "integrity": "sha512-cRVc/kyto/7E5shrWca1Wsea4y6tL9iYJE5FBCius3JQfb/4P4I295PfhgbJQBLTx6lATE4z+wK0rPM4VS2uow==", "dependencies": { - "whatwg-url": "^5.0.0" + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" }, "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" } }, "node_modules/object-assign": { @@ -1352,11 +1409,6 @@ "node": ">=0.6" } }, - "node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" - }, "node_modules/traverse": { "version": "0.3.9", "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz", @@ -1426,18 +1478,12 @@ "node": ">= 0.8" } }, - "node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" - }, - "node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" + "node_modules/web-streams-polyfill": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", + "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==", + "engines": { + "node": ">= 8" } }, "node_modules/wrappy": { @@ -1549,9 +1595,9 @@ "dev": true }, "@types/node": { - "version": "20.2.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.2.5.tgz", - "integrity": "sha512-JJulVEQXmiY9Px5axXHeYGLSjhkZEnD+MDPDGbCbIAbMslkKwmygtZFy1X6s/075Yo94sf8GuSlFfPzysQrWZQ==", + "version": "20.3.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.3.0.tgz", + "integrity": "sha512-cumHmIAf6On83X7yP+LrsEyUOf/YlociZelmpRYaGFydoaPdxdt80MAbu6vWerQT2COCp2nPvHdsbD7tHn/YlQ==", "dev": true }, "@types/qs": { @@ -1782,6 +1828,11 @@ "resolved": "https://registry.npmjs.org/csv-parse/-/csv-parse-5.4.0.tgz", "integrity": "sha512-JiQosUWiOFgp4hQn0an+SBoV9IKdqzhROM0iiN4LB7UpfJBlsSJlWl9nq4zGgxgMAzHJ6V4t29VAVD+3+2NJAg==" }, + "data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==" + }, "date-now": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", @@ -1949,6 +2000,15 @@ } } }, + "fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "requires": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + } + }, "finalhandler": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", @@ -1981,6 +2041,14 @@ } } }, + "formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "requires": { + "fetch-blob": "^3.1.2" + } + }, "forwarded": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", @@ -2330,12 +2398,19 @@ "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", "dev": true }, + "node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==" + }, "node-fetch": { - "version": "2.6.11", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.11.tgz", - "integrity": "sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w==", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.1.tgz", + "integrity": "sha512-cRVc/kyto/7E5shrWca1Wsea4y6tL9iYJE5FBCius3JQfb/4P4I295PfhgbJQBLTx6lATE4z+wK0rPM4VS2uow==", "requires": { - "whatwg-url": "^5.0.0" + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" } }, "object-assign": { @@ -2549,11 +2624,6 @@ "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", "dev": true }, - "tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" - }, "traverse": { "version": "0.3.9", "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz", @@ -2608,19 +2678,10 @@ "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", "dev": true }, - "webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" - }, - "whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "requires": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } + "web-streams-polyfill": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", + "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==" }, "wrappy": { "version": "1.0.2", diff --git a/package.json b/package.json index fc57c58..02c8369 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "local-reverse-geocoder", - "version": "0.16.2", + "version": "0.16.3", "description": "Implements a local reverse geocoder based on GeoNames.", "main": "index.js", "types": "index.d.ts", @@ -30,7 +30,7 @@ "csv-parse": "^5.4.0", "debug": "^4.3.4", "kdt": "^0.1.0", - "node-fetch": "^2.6.11", + "node-fetch": "^3.3.1", "unzip-stream": "^0.3.1" }, "repository": { @@ -48,7 +48,7 @@ "devDependencies": { "@types/cors": "^2.8.13", "@types/express": "^4.17.17", - "@types/node": "^20.2.5", + "@types/node": "^20.3.0", "cors": "^2.8.5", "express": "^4.18.2", "jsdoc": "^4.0.2", diff --git a/postinstall.js b/postinstall.js index 3485b06..6672013 100644 --- a/postinstall.js +++ b/postinstall.js @@ -18,6 +18,7 @@ const values = [ GEOCODER_POSTINSTALL_ALTERNATE_NAMES, GEOCODER_POSTINSTALL_COUNTRIES, ]; + if (values.every((val) => typeof val === 'undefined')) { console.info( '[local-reverse-geocoder] post-install: No env variables detected. Doing nothing.' @@ -26,6 +27,7 @@ if (values.every((val) => typeof val === 'undefined')) { } const geocoder = require('./index'); + try { console.info('[local-reverse-geocoder] post-install: Starting.'); geocoder.init(