Skip to content

Commit

Permalink
Merge pull request #2 from jeromemacias/update-deps
Browse files Browse the repository at this point in the history
Update all dependencies
  • Loading branch information
jeromemacias authored Apr 18, 2020
2 parents bca9687 + 7e82066 commit 0028d81
Show file tree
Hide file tree
Showing 8 changed files with 7,509 additions and 3,800 deletions.
29 changes: 12 additions & 17 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
{
"presets": [
[
"env",
{
"targets": {
"node": "6.9"
}
}
]
],
"plugins": [
"add-module-exports",
"transform-object-rest-spread"
],
"ignore": [
"*.spec.js"
]
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "10.18.1"
}
}
]
],
"ignore": ["**/*.spec.js"],
"plugins": ["add-module-exports"]
}
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4

[*.md]
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
singleQuote: true,
};
17 changes: 6 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
language: node_js
sudo: false
node_js:
- "7"
- "6.9"
- "8"
- "9"
- "10"
cache:
directories:
- node_modules
- '10'
- '12'
- 'node'
cache: npm
branches:
only:
- master
only:
- master
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
6 changes: 3 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ install:
@npm install

build-dev:
./node_modules/.bin/babel --watch -d lib/ src/ --ignore *.spec.js
./node_modules/.bin/babel --watch -d lib/ src/

build:
./node_modules/.bin/babel -d lib/ src/ --ignore *.spec.js
./node_modules/.bin/babel -d lib/ src/

test:
NODE_ENV=test ./node_modules/.bin/mocha --require babel-register src/*.spec.js
NODE_ENV=test ./node_modules/.bin/mocha --require @babel/register src/*.spec.js --timeout 5000
Loading

0 comments on commit 0028d81

Please sign in to comment.