Comments (6)
Gah I'm so sorry. I was writing a description, but then thought better of my idea halfway through writing it. Didn't realize the issue had been created.
What it was: I was a little surprised to see
Error: 'foo.enable_debug' reuses an env variable: ENABLE_DEBUG.
when I tried to do
var config = convict({
foo: {
enable_debug: {
doc: "Enable debug for the foo service",
format: Boolean,
default: true,
env: "ENABLE_DEBUG"
}
},
bar: {
enable_debug: {
doc: "Enable debug for the bar service",
format: Boolean,
default: true,
env: "ENABLE_DEBUG"
}
},
})
What I initially expected was for this to be accepted, and both foo.enable_debug and bar.enable_debug to be set to the value of process.env.ENABLE_DEBUG if it was set. In a sense, that seems more natural. (And for my use case, more convenient.) But after thinking about it, I see the merits of enforcing one setting per env variable. Somebody might be surprised if you changed one environment variable and this affected multiple settings.
Anyway, if you are not opposed to the behavior I have described, I would gladly add a pull request. If not, it would probably be a good thing to document in the README.md. (only one setting allowed per env variable)
from node-convict.
Fixed by #189
from node-convict.
what does this mean?
from node-convict.
Any movement on this? I think env variable reuse should be an overridable flag.
from node-convict.
@twitchard I didn't know about this behavior: sure at least this should be documented in the README and should also be unit tested (I haven't found any test about this behavior - just a quick search).
@twitchard @jcollum I'm personaly not against and opt-in making it possible to reuse env variables. A PR on this could be accepted if the code is clean, doesn't add to the complexity of Convict, and with a matching unit test. At the moment the only time we pass options is in the validate
method. So, to be accepted, a PR should provide a nice/easy/intuitive way to pass this option. So should we move this env variable reuse enforcement/check only in the validate
method? Please elaborate on this point. Thanks
from node-convict.
You might be interested by new options available for the validate
method that has just landed https://github.com/mozilla/node-convict#configvalidateoptions with #182 as it seems a good place to deal with options. I'm not saying it's the way to go, just that this is a possible choice. Cheers.
from node-convict.
Related Issues (20)
- Update validator to latest (major) version HOT 2
- "required" property should be a must-have HOT 3
- Convict doesn't persist date / other custom objects
- Publish [email protected] on NPM HOT 16
- 6.0.1 version of Convict-format-with-validator package is using vulnerable version of validator module HOT 1
- Could you help remove the vulnerability introduced by package yargs-parser? HOT 3
- Version 5.2.1 of convict is tagged as latest on npm HOT 2
- Support for env variable arrays HOT 1
- Error: Critical dependency: the request of a dependency is an expression when importing convict into react-app HOT 5
- how to change the environment variables in docker run command
- "Type instantiation is excessively deep and possibly infinite" when using default: null HOT 5
- Get default value of a property of an object when the object is an array item HOT 5
- Feature request: `toJson`-method HOT 1
- addParser async parse
- custom formats override set order
- Bug - Prototype Pollution on .set() HOT 20
- [Feature Request] check method to check if key exist or not
- Infer typescript types of getProperties
- Crashing on keys with dot HOT 1
- .env value doesnt override default convict config value.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-convict.