modreal-config

0.0.3 • Public • Published

modreal-config

This is an opinionated simple configuration package. It assumes:

  • configuraiton is a config folder with json files
  • the name of the json file is the name of the configuration
  • NODE_ENV is used for the app environment
  • test defaults to development, staging defaults to production
  • if no environment is specified, it is for all environments

How To Use

Add to your package as a dependency:

"dependencies": {
  "modreal-config": "modreal/config"
}

Install it:

$ npm install

Require it:

// javascript
var config = require("modreal-config");
# coffeescript
config = require 'modreal-config'

Access your configuraiton:

console.log(config.facebook)

See the next section for where to put your config json.

Config Folder Location

The config folder must be in the same directory or a parent directory of your main script file. Here are some examples of working folder setups:

+ package.json
- config
+ main.js
+ package.json
- config
- lib
  + main.js
+ package.json
- lib
  - config
  + main.js

Example JSON Files

mongo.json

{
  "production": "mongodb://alweof8a:893fhalw8efla389fhaw9efgaw@82.154.4.14:1472/app_production",
  "staging": "mongodb://alweof8a:893fhalw8efla389fhaw9efgaw@82.154.4.14:1472/app_staging",
  "development": "mongodb://localhost:27017/app_development",
  "test": "mongodb://localhost:27017/app_test"
}

Would then be available at:

console.log(process.env.NODE_ENV)
// development

config = require('modreal-config')
console.log(config.mongo)
// mongodb://localhost:27017/app_development

License

MIT


AJ Ostrow, November 2013

Readme

Keywords

none

Package Sidebar

Install

npm i modreal-config

Weekly Downloads

1

Version

0.0.3

License

none

Last publish

Collaborators

  • aj0strow