Skip to content

Commit

Permalink
Sync upstream (#8)
Browse files Browse the repository at this point in the history
* feat(elasticsearch): Default to `_doc` as type name for ES7 support

Now that we have dropped support for ES5, we can change the default type
name from `doc` to `_doc`. Either setting is compatible with ES6, but
only `_doc` is compatible with ES7.

Connects pelias/pelias#831

* chore(CI): Remove deprecated `matrix` section

Connects pelias/pelias#850

* feat(config): Default `whosonfirst.importPostalcodes` to true

These take very little additional space, and are quite useful.

We should have enabled this a long time ago.

Closes pelias#61

* fix(esclient): default esclient.apiVersion to 7.x

* feat: remove `imports.whosonfirst.importVenues`

* feat(Node.js): Drop support for Node.js 8

Node.js 8 is no longer supported as it reached [end of
life](https://github.com/nodejs/Release#release-schedule) at the end of 2019.

Connects pelias/pelias#837

* feat: Enable Postal Cities by default

For quite a while now we've had a solution to the "Postal Cities
problem" (pelias/pelias#396), but it was
disabled by default.

Enough time has passed that it should probably be enabled.

Closes pelias/pelias#396

* fix(get): support for lodash get defaultValue

* removed auth

* fix syntax

Co-authored-by: Julian Simioni <[email protected]>
Co-authored-by: Julian Simioni <[email protected]>
Co-authored-by: missinglink <[email protected]>
Co-authored-by: Joxit <[email protected]>
  • Loading branch information
5 people authored Sep 11, 2020
1 parent 234d6c5 commit 9a134a6
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 26 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ dist: xenial
notifications:
email: false
node_js:
- 8
- 10
- 12
matrix:
fast_finish: true
script: npm run travis
before_install:
- npm i -g npm
Expand Down
15 changes: 7 additions & 8 deletions config/defaults.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"esclient": {
"apiVersion": "6.8",
"apiVersion": "7.x",
"keepAlive": true,
"requestTimeout": "120000",
"hosts": [{
Expand Down Expand Up @@ -71,12 +71,11 @@
"microhood", "disputed", "postalcode", "continent", "ocean", "marinearea"
]
}
},
"auth": false
}
},
"schema": {
"indexName": "pelias",
"typeName": "doc"
"typeName": "_doc"
},
"logger": {
"level": "debug",
Expand All @@ -92,7 +91,7 @@
"adminLookup": {
"enabled": true,
"maxConcurrentRequests": 100,
"usePostalCities": false
"usePostalCities": true
},
"blacklist": {
"files": []
Expand Down Expand Up @@ -120,10 +119,10 @@
},
"whosonfirst": {
"datapath": "/mnt/pelias/whosonfirst",
"importVenues": false,
"polygons": false,
"simplifyPolygons": false,
"simplificationRate": 0.0003
"simplificationRate": 0.0003,
"polygons": false,
"importPostalcodes": true
}
}
}
7 changes: 3 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,14 @@ function getConfig(deep) {
/*
* Because it's not enumberable, the get function has to be added every time after
* cloning an object with _.merge or _.assign
*
* see: https://lodash.com/docs/4.17.15#get
*/
function addGetFunction(object) {
const getFunction = function get(key) {
return _.get(this, key);
};

// set 'get' convenience function on returned object
Object.defineProperty(object, 'get', {
value: getFunction,
value: _.get.bind(null, object),
enumerable: false // allows comparison to `expected.json` in tests
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"url": "https://github.com/pelias/config/issues"
},
"engines": {
"node": ">=8.0.0",
"node": ">=10.0.0",
"npm": ">=1.4.3",
"elasticsearch": ">=1.1.1"
},
Expand Down
13 changes: 6 additions & 7 deletions test/expected-deep.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"esclient": {
"apiVersion": "6.8",
"apiVersion": "7.x",
"keepAlive": true,
"requestTimeout": "120000",
"hosts": [{
Expand Down Expand Up @@ -76,12 +76,11 @@
"microhood", "disputed", "postalcode", "continent", "ocean", "marinearea"
]
}
},
"auth": false
}
},
"schema": {
"indexName": "pelias",
"typeName": "doc"
"typeName": "_doc"
},
"logger": {
"level": "debug",
Expand All @@ -97,7 +96,7 @@
"adminLookup": {
"enabled": true,
"maxConcurrentRequests": 100,
"usePostalCities": false
"usePostalCities": true
},
"blacklist": {
"files": []
Expand Down Expand Up @@ -129,10 +128,10 @@
},
"whosonfirst": {
"datapath": "~/whosonfirst",
"importVenues": false,
"polygons": false,
"simplifyPolygons": false,
"simplificationRate": 0.0003
"simplificationRate": 0.0003,
"importPostalcodes": true
}
}
}
19 changes: 16 additions & 3 deletions test/generate.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

var path = require('path'),
config = require('../'),
defaults = require('../config/defaults');
const path = require('path');
const config = require('../');
const defaults = require('../config/defaults');
const Joi = require('@hapi/joi');

module.exports.generate = {};
Expand Down Expand Up @@ -271,6 +271,19 @@ module.exports.generate.validate = (test) => {
t.end();
});

test('get function supports defaultValue', (t) => {
// set the PELIAS_CONFIG env var
process.env.PELIAS_CONFIG = path.resolve(__dirname + '/../config/env.json');
const c = config.generate();

t.equals(c.get('foo', 'DEFAULT'), 'DEFAULT', 'default value used for keys that do not exist');

// unset the PELIAS_CONFIG env var
delete process.env.PELIAS_CONFIG;

t.end();
});

test('generateDefaults returns default config always', function(t) {
// set the PELIAS_CONFIG env var, this config should NOT be used
process.env.PELIAS_CONFIG = path.resolve( __dirname + '/../config/env.json' );
Expand Down

0 comments on commit 9a134a6

Please sign in to comment.