1.0.24 • Published 9 years ago

monfig v1.0.24

Weekly downloads
-
License
MIT
Repository
-
Last release
9 years ago

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"
  //   }
  // }
}
1.0.24

9 years ago

1.0.23

9 years ago

1.0.22

9 years ago

1.0.21

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

10 years ago