6.0.0 • Published 9 months ago

pelias-config v6.0.0

Weekly downloads
439
License
MIT
Repository
github
Last release
9 months ago

This repository is part of the Pelias project. Pelias is an open-source, open-data geocoder originally sponsored by Mapzen. Our official user documentation is here.

Pelias Configuration

This repository defines standard configuration for all parts of the Pelias geocoder. It contains tools for Pelias packages to read from configuration in a standardized way, and for Pelias users to set up their own configuration.

Greenkeeper badge

NPM

Installation

$ npm install pelias-config

Usage

Create a new Pelias config:

var config = require('pelias-config');

// use the default settings
var settings = config.defaults;

development settings

var config = require('pelias-config');

// generate development specific settings
var settings = config.generate();

local config

the easiest way to get a custom config is to create a file named ~/pelias.json.

you can copy the example file from here: https://github.com/pelias/config/blob/master/config/local.json

this file will be checked for settings whenever you run imports and will override the defaults; it is particularly useful for specifying datasource paths during development.

production settings

sysadmin and ops engineers can override the default settings on the server by launching any code which requires this module by supplying an ENV var with the path to their custom json config.

$ PELIAS_CONFIG=/path/to/settings/file.json node app.js

Note: by default the merge is deep (it replaces the defaults with any properties that are present in the env config). The developer can disable deep merging to use only local configuration settings.

var config = require('pelias-config');

// shallow merge config settings from a path supplied in the env var
var settings = config.generate( false );

// deep merge config settings from a path supplied in the env var
var settings = config.generate( true );
var settings = config.generate();

You can test the result of merging your env config with the following bash oneliner:

npm install pelias-config; \
PELIAS_CONFIG=/path/config.json \
node -e "console.log( JSON.stringify(require('pelias-config').generate(), null, 2) );";

Validation

Aside from deep, the generate function takes an additional parameter named schema that uses Joi to validate that the configuration is useable. An error is thrown if the generated configuration does not validate against the schema.

Exporting & Debugging

The generated config will be a standard Javascript object:

var config = require('pelias-config'),
    settings = config.generate();

console.log(JSON.stringify(settings, null, 2));
// {
//    "api": {
//       ...
//    },
//    "imports": {
//      ...
//    }
//  }

You can pretty print the generated config with any package you like or with JSON.stringify. Using the third parameter to JSON.stringify for indentation may be helpful:

var config = require('pelias-config'),
    settings = config.generate();

console.log( JSON.stringify(settings, null, 2) );

NPM Module

The pelias-config npm module can be found here:

https://npmjs.org/package/pelias-config

Contributing

Please fork and pull request against upstream master on a feature branch.

Pretty please; provide unit tests and script fixtures in the test directory.

Running Unit Tests

$ npm test

Continuous Integration

CI tests every release against all supported Node.js versions.

6.0.0

9 months ago

5.2.0

2 years ago

5.1.0

3 years ago

5.0.1

4 years ago

5.0.0

4 years ago

4.12.1

4 years ago

4.12.0

4 years ago

4.10.0

5 years ago

4.11.0

5 years ago

4.9.1

5 years ago

4.9.0

5 years ago

4.8.0

5 years ago

4.7.0

5 years ago

4.6.0

5 years ago

4.5.0

5 years ago

4.4.0

5 years ago

4.3.0

5 years ago

4.2.0

5 years ago

4.1.0

5 years ago

4.0.0

6 years ago

3.11.0

6 years ago

3.10.0

6 years ago

3.9.0

6 years ago

3.8.1

6 years ago

3.8.0

6 years ago

3.7.0

6 years ago

3.6.1

6 years ago

3.6.0

6 years ago

3.5.0

6 years ago

3.4.0

6 years ago

3.3.0

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.17.0

6 years ago

2.16.0

6 years ago

2.15.0

6 years ago

2.14.1

6 years ago

2.14.0

7 years ago

2.13.0

7 years ago

2.12.1

7 years ago

2.12.0

7 years ago

2.11.0

7 years ago

2.10.0

8 years ago

2.9.0

8 years ago

2.8.0

8 years ago

2.7.1

8 years ago

2.7.0

8 years ago

2.6.0

8 years ago

2.5.0

8 years ago

2.4.0

8 years ago

2.3.1

8 years ago

2.3.0

8 years ago

2.2.0

8 years ago

2.1.0

8 years ago

2.0.0

8 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.2.0

9 years ago

0.1.6

9 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago

0.0.0

10 years ago