mozilla / node-convict

Featureful configuration management library for Node.js
Other
2.35k stars 146 forks source link

Can't use 'default' key in my config. #377

Closed viktorlv30 closed 1 year ago

viktorlv30 commented 4 years ago

I need a 'default' key in my config, like { "endpoints": { "default": { "base-url": "http://localhost:5000", "path": "/v1" }, "auth": { "base-url": "/auth/v1", "path": "/token" } } }

I create a schema: const schema = { endpoints: { "default": { "base-url": { default: "http://localhost:5000", doc: 'Default domain', format: String }, "path": { default: "/v1", doc: 'Default API version', format: String } }, auth: { "base-url": { default: "/auth/v1", doc: 'Auth path', format: String }, "path": { default: "/token", doc: 'To get auth token', format: String } } } }

Then, create config with this schema const config = convict(schema);

After I try to get entire config: console.log(config.get()); And receive wrong configuration: / { endpoints: { 'base-url': { default: 'http://localhost:5000', doc: 'Default domain', format: [Function: String] }, path: { default: '/v1', doc: 'Default API version', format: [Function: String] } } } /

But should be: / { endpoints: { default: { 'base-url': 'http://localhost:5000', path: '/v1' }, auth: { 'base-url': '/auth/v1', path: '/token' } } } /

A-312 commented 4 years ago

I did this work : https://github.com/mozilla/node-convict/pull/357/commits/4f3c6519f70c42c647d334d834b53881b284b67f

viktorlv30 commented 4 years ago

image Maybe I'm doing something wrong?

convict version is 6.0.0

A-312 commented 4 years ago

Oh, my bad you can't see the PR status with the link I give you. The PR with the commit was closed because they was to many conflict (one of my first commit/change in this PR was rejected).

You have two solution : Make a new PR (and reproduce the change) or use my fork.

Some links:

ronkorving commented 4 years ago

Damn, just came here to report exactly this.

@A-312 Any chance you could make a smaller PR that fixes just this issue?

A-312 commented 4 years ago

I already did a big work on my fork

ronkorving commented 4 years ago

@A-312 Oh, that looks interesting! Thanks, I'll have a closer look :)