https://github.com/yornaath/monfig
Environment aware, asynchronous, folder based config building for node
https://github.com/yornaath/monfig
Last synced: 7 months ago
JSON representation
Environment aware, asynchronous, folder based config building for node
- Host: GitHub
- URL: https://github.com/yornaath/monfig
- Owner: yornaath
- Created: 2015-07-05T11:48:50.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-04-29T19:23:50.000Z (over 9 years ago)
- Last Synced: 2025-01-22T07:35:41.427Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# monfig
Environment aware, asynchronous, folder based config building for Nodejs```
npm install monfig
```### API
This package is basically the way [Sails.js](http://sailsjs.org/) does its configuration.
See their docs to get a more in depth look at how the folder structure and naming decides the config objects structure.[Sails.js Config docs](http://sailsjs.org/documentation/concepts/configuration)
#### monfig.build(options):Promise\
```javascript
import {build} from "monfig"build({ basePath: "./config", env: process.env.NODE_ENV })
.then((config) => {
// config == {
// "reddis": {
// "url": "productionurl"
// },
// "facebook": {
// "apikey": "prodkey"
// }
// }
})
```#### Async config
/config/foo.js
```javascript
import fetch from 'isomorphic-fetch'export default async function factory() {
const response = await fetch('192.168.1.13:1337/foo.json')
// response == {
// "bar": "lol"
// }
return response.json()
}
```app.js
```javascript
import {build} from "monfig"export default async function init() {
const config = await build({ basePath: "./config", env: process.env.NODE_ENV })
// config == {
// "foo": {
// "bar": "lol"
// }
// }
}
```