Installation via NPM:
$ npm install confeager --save
Comparability Note: ConfEagerJS uses Smoke Screen library to define and validate object schemas and types at runtime. This requires usage of EcmaScript decorators. While EcmaScript doesn't officially support decorators yet, the examples below are implemented in TypeScript, but may also be implemented in any other way that compiles decorators.
Consider a YAML configuration file
host: 0.0.0.0 # stringport: 8080 # numberhttps: false # booleanlogLevel: INFO # enumnestedConfiguration: # objectnestedProperty: 1234arrayConfiguration: # array- 1234- 2345
Then a consumer written in TypeScript:
;;// load config data from a yaml file with a watch interval of// 10 milliseconds into a conf eager source.;// now use the source to instantiate a configuration object// and bind it to the source, so that when the source data// updated, the configuration instance immidietaly gets updated too.;// that's it, let's use it!conf.host; // => "0.0.0.0"conf.port; // => 8080conf.useHttps; // => falseconf.logLevel; // => LogLevel.INFOconf.nestedConfiguration.nestedProperty; // => 1234conf.arrayConfiguration; // => [1234, 2345]conf.optionalProperty; // => "value"
Full documentation can be found on the project WIKI on GitHub.
ConfEagerJS is designed with two main charachteristics: being eager and being strongly-typed. This is a very powerful combination that provides a few main advantages.
As opposed to popular configuration libraries, ConfEagerJS provides you with an
interface for declaring your exact expectations from the configuration data. In addition, properties are eagerly loaded and validated. This combination renders a system that validates your entire configuration data source at boot time. The existance and value validity of each property in the source is validated immidiately. This also means no need to check for
null and no null pointer errors either. This means no more typos when reading from the configuration, and most importantly, this means that to discover these kind of bugs you do not have to discover the exact control flow that triggers it, but rather let ConfEager find it for you when it loads.
Additionally, ConfEagerJS is aimed to provide simple means to easily implement any data source you like, seamlessly get data updates from it without the need to restart your application, and consume any property type you would like from it.
ConfEagerJS follows a big sister project for Java.
ConfEagerJS is registered under license.
Really, any kind of contribution will be warmly accepted. (: