Skip to content

Latest commit

 

History

History
58 lines (41 loc) · 1.31 KB

README.md

File metadata and controls

58 lines (41 loc) · 1.31 KB

-----------------------------------------------------

➤ @burlzad/config

A zero dependency utility library to build configs

Introduction

@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.

Principles

  • Simple - Get started fast
  • Lightweight - A thin layer to abstract your config
  • Zero dependency - No worries about complicated dependency resolution

Quick Start

  1. Install
npm i @burlzad/config
  1. 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',
  }),
});
  1. Use
import config from './config';

if (config.SOME_ENV_VAR === 'someProdEnvVar') {
  doSomething();
}