Inspired by BitFis/config
$ npm install yaml-config-ts --save
Use config for yaml config files in Typescipt projects. For example you might have a project with the following config.yml file in the project dir.
See example directory to check sample code.
You can substitute variables in the config.yml like this.
dns: myapp.com
app:
url: http://${dns}/home
cache: redis
db:
location: mysql-db-prod
This config would yield the following.
console.log(config.app.url);
// outputs - http://myapp.com/home
Instead of having a file named config.yml
with all of your environment settings in place, you could have a config
folder
at the root level of your project. This module will read in every .yml
file, and return an object that looks like:
{
[file-name]: [parsed-file-contents],
...,
}
if you need to do cross-file referencing, you can, via dot-notation:
# file `a.yml`
foo: bar
#file `b.yml`
baz: ${a.foo}
will get you
{
a: {foo: 'bar'},
b: {baz: 'bar'}
}
- Circular dependencies are not handled