1

The Problem

In my /config directory, I have two configuration files. One is created by sequelize-cli and contains database settings for development, test, and production. The other is a configuration file used by node-config.

I find myself having to duplicate database configuration in the two files in order to make them available for e.g. migrations, as well as for calls to config.get('some_config') from within my application code. By default the two files look like this:

config.json

    {
      "development": { 
        "database": "db-name",
        "username": "db-username",
        "password": "db-password",
        ...
      },
      "test": { ... },
      "production": { ... }
    }

development.json

    {
      "app": {
        "name": "app-name"
      },
      "dbconf": {
        "database": "db-name",
        "username": "db-username",
        "password": "db-password",
        ...
      }
    }

Desired Outcome

Instead of duplicating database configuration across different files, I want to I want to use node-config to load settings from the file that sequelize init created (config.json).

This does not appear to be possible, and node-config is unable to read settings from config.json.

Alternately, I could set development.json as the config file for sequelize-cli.

This works, but only if all the database information is at the top level of the object, and I would like the flexibility of nesting the information.

Is there a way to make this work, and if not, what is a better approach?

llnathanll
  • 80
  • 6

0 Answers0