YAML configuration for NodeJS
config/default.yml
:
foo: "bar"
list:
- 1
- 2
- 3
import configYaml from "config-yaml";
const config = configYaml(`${__dirname}/config/default.yml`);
console.log(config.foo); // "bar"
console.log(config.list[1]); // 2
config/production.yml
:
imports:
- { resource: "default.yml" }
- { resource: "routing/api.yml", property: "routing.api" }
foo: "hello"
tic: "tac"
import configYaml from "config-yaml";
const config = configYaml(`${__dirname}/config/production.yml`);
console.log(config.foo); // "hello"
console.log(config.routing.api); // Configuration from routing/api.yml
Variable | Description |
---|---|
%__dirname% |
Directory path of the current YAML file |
%__filename% |
Current YAML file path |