Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

env ignores lowerCase option #261

Closed
OmgImAlexis opened this issue Apr 6, 2017 · 2 comments
Closed

env ignores lowerCase option #261

OmgImAlexis opened this issue Apr 6, 2017 · 2 comments

Comments

@OmgImAlexis
Copy link

I don't know if I'm missing something or not reading the docs correctly and I'm hoping someone here can help. Currently I'm using this setup in my app with a config.json file in the root of my repo. If the app uses docker instead of just launching it via the cli I would like to use redis inside of another container hence the need for ENV.

What I've noticed is that even when passing in DNS_PORT it's being added to the store with all capitals meaning when get() is called it finds the lowercase one even since there's now two DNS and dns fields in the store.

Maybe the lowerCase option should add the fields using lowerCase instead of just looking them up with lowerCase?

nconf.use('file', {
    file: path.join(__dirname, 'config.json')
}).defaults({
    redis: {
        host: "127.0.0.1",
        port: 6379
    },
    dns: {
        port: 5353
    }
}).env({
    separator: '_',
    lowerCase: true,
    whitelist: [
        'DNS_INTERFACE',
        'DNS_PORT',
        'DNS_ZONE',
        'REDIS_HOST',
        'REDIS_PORT',
        'LOGS_LEVEL'
    ]
});

The last line uses nconf.get('dns:port'); to set the server's port.
The output is from console.log(nconf.get());.

➜  redis-dns git:(master) ✗ export DNS_PORT=6000 && ./node_modules/.bin/babel-node index.js 
{ DNS: { PORT: '6000' },
  redis: { host: '127.0.0.1', port: 6379 },
  dns: { port: 2103, interface: '127.0.0.1', zone: 'redis-dns.local' },
  type: 'literal',
  logs: { level: 'warning' } }
Server running at 127.0.0.1:2103
@ifuyivara
Copy link

did you find the issue? I'm having the same problem here

@OmgImAlexis
Copy link
Author

The issue is stated above. I ended up just switching to configstore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants