0.2.4 • Published 8 years ago

config-autoload v0.2.4

Weekly downloads
5
License
GNU
Repository
github
Last release
8 years ago

config-autoload

Npm module for autoloading config files. It uses https://github.com/motdotla/dotenv module for loading environment variables from .env file

#quick start create same folder and file structure

	myapp/config
	myapp/config/.env
	myapp/config/config.js

config.js example :

var path = require('path');
var _ = require('lodash');

module.exports = {
	path : path.normalize(__dirname + "/.."),
	name : process.env.NAME,
	port : _.parseInt( process.env.PORT )
};

.env example

NAME=xyz
PORT=3306

later in code require config-autoload and have access to object defined in config.js

var config = require('config-autoload');
console.log(config); 
//output
{ 
	path : '/home/xyz/myapp/', 
	name : 'xyz', 
	port : 3306  
}

create a folder for config files myapp/config

for development create a .env file with env variables

myapp/config/.env

create a config.js file for handling variables

myapp/config/config.js
0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago