Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/david-vandensteen/yaml-loader
https://github.com/david-vandensteen/yaml-loader
Last synced: 4 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/david-vandensteen/yaml-loader
- Owner: David-Vandensteen
- License: mit
- Created: 2024-03-07T13:34:21.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-03-07T14:18:42.000Z (8 months ago)
- Last Synced: 2024-03-07T15:36:00.480Z (8 months ago)
- Language: JavaScript
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Node.js](https://img.shields.io/badge/Node.js-20.x-green.svg)](https://nodejs.org/en/download/)# yaml-loader
## Install
```cmd
npm i [email protected]:David-Vandensteen/yaml-loader.git#release/1.0.0
```This function reads and parses YAML configuration files.
The function searches for the specified YAML file and returns the corresponding configuration object.
If the YAML file is not found, it looks for fallback files in the provided order and returns the configuration object from the first found file.
If no file is found, an error is thrown.```javascript
try {
const config = YAMLLoader('config.yaml', { fallBack: ['config.production.yaml', 'config.default.yaml'] });
console.log('Database configuration:', config.db);
// Use the config object to connect to the database
} catch (err) {
console.error('Error loading configuration:', err);
}
```