@punkish/zconfig

1.0.4 • Public • Published

zconfig

There are lots of wonderful utilities for storing and managing config information. This is not one of them. But, if you want a dependency-free utility, consider using this, a really zimple tool that works for me.

How To

Initialize a new config instance and access the settings as follows

import { Config } from './index.js';
const config = new Config().settings;
console.log(config)

See the accompanying example.js and the sample settings in config directory. The base setting in development.cjs (or default.cjs) is always read first. Then, depending on the process.env.NODE_ENV, the applicable test.cjs or production.cjs are deep-merged into the base settings. All the settings are available via the resulting config object.

process.env.NODE_ENV can be passed in via dotenv or by any other method setting the NODE_ENV environment variable. For example, by prefixing the call for your program as $ NODE_ENV=production node index.js

Important Notes:

  • the config directory has to be at the root of your application.
  • the settings have to use module.exports and have to have the .cjs suffix.

Readme

Keywords

Package Sidebar

Install

npm i @punkish/zconfig

Weekly Downloads

0

Version

1.0.4

License

CC0-1.0

Unpacked Size

11 kB

Total Files

8

Last publish

Collaborators

  • punkish