3.1.0 • Published 11 months ago

confres v3.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Confres

Confres is a Framework-agnostic runtime configuration resolver with full TypeScript support.

tl;dr :arrow_right: Check this example :arrow_left:

Features

  • load configuration from various sources
  • merge loaded configuration objects
  • process / validate the final configuration
  • exceptions with extensive information (eg. where and how was defined value that caused the error or how can be defined a missing value)
  • configurable error message formatter
  • fully extensible - supports custom loaders and processors
  • preconfigured resolvers

Supported data sources:

  • environment variables
  • .env files (using dotenv)
  • JSON files

Supported processors:

Installation

You can get latest release with type definitions from NPM:

npm install confres@beta --save

# if you want to use Yub processor / validator
npm install yup --save

# if you want to have colorful error messages
npm install chalk@^4.0.0 --save

Components

Loaders

Loaders handle configuration from various sources.
You can create your own loader by implementing Loader interface.

Available loaders

Class nameDescription
ValueLoaderInline value loader.
JsonFileLoaderLoads JSON files.
ProcessEnvLoaderLoads process.env.
DotEnvLoaderLoads .env files.
OptionalLoaderMakes any of above loaders optional.

Processors

Processors could transforms previously loaded configuration in any way.
You can create your own processor by implementing Processor interface.

Available processors

Class nameDescription
YupProcessorCast values and validates the configuration against schema.

Resolver

Resolver loads configuration using specified loaders, merges them in order and processes them with processors. If any loader or processor throw an exception, Resolver collects information about the cause and decorates exception with these information.

Error message formatter

Error message formatter is responsible for producing pretty human-readable message for the user from exceptions decorated by Resolver.

3.1.0

11 months ago

3.1.0-beta.1

11 months ago

3.0.0-beta.1

1 year ago

3.0.0-beta.2

1 year ago

3.0.0

1 year ago

2.0.0-beta.2

2 years ago

2.0.0-beta.1

2 years ago

2.0.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.0.0-beta.1

2 years ago