1.0.5 • Published 5 years ago

node-config-reader v1.0.5

Weekly downloads
4
License
ISC
Repository
github
Last release
5 years ago

node-config-reader

read and merge config for multiple env support

Install

# with npm
npm install node-config-reader
# or using yarn
yarn add node-config-reader

Usage

import envLoad from 'node-config-reader';

const finalConfig = envLoad({
    configDir: __dirname,
    defaultEnv: 'default',
    currentEnv: 'dev',
});

Function interface

// function to get file name from env name
type FileNameResolver = (envName: string) => string;

/**
 * default env config file name resolver
 * @param envName env name, such as 'default', 'production', 'dev'
 */
function defaultConfigFileNameResolver(envName: string): string {
    return `config.${envName}`;
}

interface Args {
    // absolute path to config dir
    configDir: string;
    // default env name
    defaultEnv?: string;
    // current env
    currentEnv: string;
    // function to resolve config file name based on env
    fileNameResolver?: FileNameResolver;
}

type EnvLoad<T = any> = (args: Args) => T;
1.0.2

5 years ago

1.0.1

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.0

5 years ago