monfig

1.0.24 • Public • Published

monfig

Environment aware, asynchronous, folder based config building for Nodejs

API

This package is basically the way Sails.js 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

monfig.build(options):Promise<Object>

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

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

import {build} from "monfig"
 
export default async function init() {
  const config = await build({ basePath: "./config", env: process.env.NODE_ENV })
  // config == {
  //   "foo": {
  //     "bar": "lol"
  //   }
  // }
}

Readme

Keywords

Package Sidebar

Install

npm i monfig

Weekly Downloads

0

Version

1.0.24

License

MIT

Last publish

Collaborators

  • gorillatron