Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arstgit/ya-config-loader
JSON config loader.
https://github.com/arstgit/ya-config-loader
Last synced: about 10 hours ago
JSON representation
JSON config loader.
- Host: GitHub
- URL: https://github.com/arstgit/ya-config-loader
- Owner: arstgit
- License: mit
- Created: 2020-01-19T15:53:21.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-24T13:36:24.000Z (almost 5 years ago)
- Last Synced: 2024-10-29T01:19:52.438Z (18 days ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ya-config-loader
[![Build Status](https://travis-ci.org/derekchuank/ya-config-loader.svg?branch=master)](https://travis-ci.org/derekchuank/ya-config-loader)
[![npm version](https://badge.fury.io/js/ya-config-loader.svg)](http://badge.fury.io/js/ya-config-loader)## Super simple to use
A simple config loader, support `json` only.
## Installation
```
npm install ya-config-loader
```## Usage
Usually, you will create a `config` directory including `default.json`, `test.json` and `production.json` in your project root directory. And using `NODE_ENV=test` to overwrite(merge) `default.json` with `test.json` is very helpful. Specifing environment variables such as `PORT=3000` can also be used to overwrite with highest priority.
First, Invoking the module without params to load the `config` in `process current working dir` is necessary:
```js
require("ya-config-loader").load();
const config = require("ya-config-loader");
```or
```js
const config = require("ya-config-loader").load();
```Alternatively, invoking with path string can be used to overwrite(merge) the `config` of `process current working dir`:
```js
require("ya-config-loader").load("path/to/config");
const config = require("ya-config-loader");
```or
```js
const config = require("ya-config-loader").load("path/to/config");
```After step 1, `require("ya-config-loader")` will become one `global` plain javascript object with only configs entries in it. When you need it:
```js
const config = require("ya-config-loader");
```And you can modify this plain object freely.