2.0.0 • Published 19 days ago

@uwu/configmasher v2.0.0

Weekly downloads
-
License
CC0-1.0
Repository
github
Last release
19 days ago

configmasher

configmasher is a config aggregator, it will reunite all your configs from different locations and different formats into a single object.

it was heavily inspired by unjs's c12 project.

Install

npm i @uwu/configmasher

Example

The config files used in this example are available here

configs
├─── .env
├─── hello.env
└─── jsonfile.json
// CommonJS
const loadConfig = require("configmasher");

// ESM
import loadConfig from "configmasher";

const { config, layers } = await loadConfig({
  environmentFile: true,
  processEnvironment: true,

  name: "myprogram",

  configs: [
    { "jsonobject": "hello from a json object" },
    "jsonfile.json",
    "hello.env"
  ],

  defaults: {
    "defaultEntry": "this is a default item",
    "helloenvfile": "this is a default entry that will be overwritten"
  }
});

console.log(config);
/*
{
  "helloprocessenv": "this will be config.helloprocessenv",
  "envfile": "hello from the .env file",
  "envfile2": "helo",
  "helloenvfile": "this will be config.helloenvfile",
  "nested": {
    "entry": "this will be config.nested.entry"
  },
  "jsonobject": "hello from a json object"
}
*/
2.0.0

19 days ago

1.1.1

9 months ago

1.1.2

9 months ago

1.0.2

1 year ago

1.1.0

1 year ago

1.0.1

2 years ago

1.0.0

2 years ago