A zero dependency utility library to build configs
@burlzad/config
organizes configuration for your service.
It allows you to define different environments in which to run and provide a system to resolve environment variables to configuration values.
It leans upon static typing to ensure access is valid and is simply a thin layer to validate config is loaded correctly and allow you to access the types you defined.
- Simple - Get started fast
- Lightweight - A thin layer to abstract your config
- Zero dependency - No worries about complicated dependency resolution
- Install
npm i @burlzad/config
- Configure
export const config = configure({
test: () => ({
SOME_ENV_VAR: 'someTestEnvVar',
}),
production: () => ({
SOME_ENV_VAR: 'someProdEnvVar',
}),
DEFAULT: (source = {}) => ({
SOME_ENV_VAR: source.SOME_ENV_VAR || 'default',
}),
});
- Use
import config from './config';
if (config.SOME_ENV_VAR === 'someProdEnvVar') {
doSomething();
}