node package manager



Cascadia is an opinionated cascading static configuration loader. It loads static configuration files such that common configuration files are loaded first, followed by a set of environment configuration files which are then optionally followed by a set of machine specific local configurations files.


Each configuration file is simply a CommonJS module of a statically defined JSON object (module.exports = {}). Cascadia doesn't attempt to perform any clever object merging. If you have a config parameter in common and you override it with an environment specific config the entire value of the latter config will override the entire value of the prior config.

Cascadia expects the configuration directory it's reading to be laid out in a very specific way. I would make a joke about convention over configuration in a configuration loader here, but all jokes seem to elude me at the moment. In either case, the bare minimum directory structure cascadia expects is as follows.

  \_ /common
  \_ /local

However, typically you'll want to have environment specific configurations. Cascadia doesn't impose any specific environments on you and it's up to you to define your own environments in the directory structure and tell cascadia which one to use. So say you had dev, stage and prod environments, you're cascadia configuration folder may look like the following

  \_ /common
  \_ /dev
  \_ /stage
  \_ /prod
  \_ /local

cascadia(location, env = false, local = true)

This module only exports a single function cascadia(). This function takes a required location argument with optional env and local arguments. The location argument is a path to the base configuration folder. The env argument specifies the set of environment configurations to load that should corespond to the name of the folder within the base configuration folder where the environment configurations can be found. If env is false then no environment variables will be loaded. The local variable is just a toggle to enable or disable the loading of local configuration files found in the local folder

  • @param {string} location - The path to the base configuration folder
  • @param {string|boolean} env - The optional environment to load or false
  • @param {boolean} local - The toggle to load local configs
  • @returns {object} - The resulting configuation