confres v3.1.0
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:
- Yup validator
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 name | Description |
---|---|
ValueLoader | Inline value loader. |
JsonFileLoader | Loads JSON files. |
ProcessEnvLoader | Loads process.env . |
DotEnvLoader | Loads .env files. |
OptionalLoader | Makes 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 name | Description |
---|---|
YupProcessor | Cast 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.
11 months ago
11 months ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago