Skip to content

Cannot use dot in keys when using Object format #250

Open
A-312/node-blueconfig
#1
@jonaskello

Description

@jonaskello

I have a case where an URL is a key in an object that is a default value for a setting. Something like this:

export const conf = convict({
  npmrc: {
    doc: "Config for installing plugin packages.",
    format: "Object",
    default: {
      registries: {
        "@foo": "https://npm.foo.com/",
      },
      authTokens: {
        "https://npm.foo.com/": {
          type: "Bearer",
          token: "XXXX",
        },
      },
    },
  }
}

This fails to validate with this error:

Error: cannot find configuration param 'npmrc.authTokens.https://npm.foo.com/'
    at walk (/XXXserver.js:74759:15)
    at flatten (/XXX/server.js:74405:15)
    at validate (/XXX/server.js:74449:24)
    at Object.validate (/XXX/server.js:74911:20)

I guess it is becuase convict supports dot notation in the string sent to get() which gets confusing when the keys also have dots. Is there a workaround for this so we can use URLs as keys?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions