simple-conf
Super simple config module that allows you to easily share some config options for your application with a few helpers. I wrote this because I needed something fairly static for my express sub applications.
Heads up!
I am still fairly regularly breaking, refactoring and perfecting my universal strategy to making one simple config file... to rule them all. (jk, if i wanted that i wouldn't have written this in coffeescript right? :neckbeard:)
Example
var Config = ; var options = title: "Some example title" db_path: "test" port: 1337 init: false; var config = moduleexports = options;
Quick overview
new Config(options)
Returns
If your options object looks like this:
title: "Some example title" db_path: "test" port: 1337 init: false
Your output would be:
title: "Some example title" protocol: "http://" host: "127.0.0.1" port: 1337 uri: "http://127.0.0.1:1337" db_connection: "mongodb://127.0.0.1:27017" db_path: "test" db_uri: "mongodb://127.0.0.1:27017/test" init: false
config.saveFile(path, callback)
Stores your config data to config.json
, so you can load your app with that instead of this module. I use it for client setups, so when they deploy their application I don't need to worry about a db being down, or this module not building.
Returns
config.json
in the path specified
config.extended(req)
Useful when you have access to the req
object in express.js
Returns
ip
- client ip, not the server/router ipuser
- ifreq.user
exists it stores it to thisengine
- application uri
config.folders(path, callback)
Creates folders easily so you don't have to deal with .placeholder
or alike workarounds
Returns
success
orfailure
message
config.colors()
Helpful when dealing with a lot of console.
Returns
red
cyan
reset
config.secret()
Keeps your sensitive stuff in a prototype and grabs from process.env.NODE_PASS
defaults inside source
Returns
secret
config.locals()
Deprecated, planning on destroying this soon.
config.init(app)
If you're building a lot of express apps this binds the title and port, more coming soon..
License
The MIT License (MIT) Copyright (c) 2013 David Higginbotham Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.