Skip to content

Commit

Permalink
Add node version badge on README
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromemacias committed Apr 16, 2020
1 parent aa0eb26 commit 238f024
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# rob-config

[![NPM version](http://img.shields.io/npm/v/rob-config.svg)](https://www.npmjs.org/package/rob-config)
![node-current](https://img.shields.io/node/v/rob-config)
[![Build Status](https://travis-ci.org/jeromemacias/node-rob-config.svg?branch=master)](https://travis-ci.org/jeromemacias/node-rob-config)

Robust configuration module for nodejs, built on top of [`convict`](https://github.com/mozilla/node-convict).
Expand All @@ -16,11 +18,11 @@ Robust configuration module for nodejs, built on top of [`convict`](https://gith

So I wanted something:

- Easy to use like `config`
- With schema and documentation like `convict`
- With possibility to override with env variable or command line argument like `convict`
- With a command to validate config for dev AND before deployment to production
- With a command to see the builded config depends on env and default value (easier to debug)
- Easy to use like `config`
- With schema and documentation like `convict`
- With possibility to override with env variable or command line argument like `convict`
- With a command to validate config for dev AND before deployment to production
- With a command to see the builded config depends on env and default value (easier to debug)

Here it is and it's very easy to migrate from `config` or `convict`.

Expand All @@ -31,6 +33,7 @@ Define a config schema, simple object.
See https://github.com/mozilla/node-convict#the-schema for documentation about schema definition.

For example: `config/schema.js`

```js
module.exports = {
env: {
Expand All @@ -50,18 +53,19 @@ module.exports = {
format: 'nat',
default: 60 * 1000, // 1 minutes
},
}
},
};
```

Then, define the first config file.

For example: `config/development.js`

```js
module.exports = {
api: {
port: 3001 // test with "nothing" value to see validation error
}
port: 3001, // test with "nothing" value to see validation error
},
};
```

Expand All @@ -72,18 +76,19 @@ See https://github.com/mozilla/node-convict#custom-format-checking for documenta
`convict.addFormats()` will be call under the hood.

For exemple: `config/formats.js`

```js
module.exports = {
'float-percent': {
validate: function(val) {
validate: function (val) {
if (val !== 0 && (!val || val > 1 || val < 0)) {
throw new Error('must be a float between 0 and 1, inclusive');
}
},
coerce: function(val) {
coerce: function (val) {
return parseFloat(val, 10);
}
}
},
},
};
```

Expand Down Expand Up @@ -115,7 +120,6 @@ Run `./node_modules/.bin/rob-config describe`:
const config = require('rob-config');

console.log(config.get('api.port'));

```

### Change config dir
Expand Down

0 comments on commit 238f024

Please sign in to comment.