1.0.4 • Published 8 years ago

node-simple-config v1.0.4

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

Node Simple Config

Purpose

Simplifies loading of configuration file. Other modules seem to over-complicate it. Inspired by Laravel

Installation

npm install node-simple-config

Features

  • Loads configuration parameters in key-value manner
  • Reloads configuration file

Usage

.env

ENV=DEV
LOG_LEVEL=DEBUG
DB_HOST_NAME=database.some-dns.myserver.com
DB_HOST_PORT=6379
DB_HOST_DATABASE=Users
DB_HOST_PASSWORD=passwerd

example.js

// Loads config file from .env file
var config = require('node-simple-config');

var dbHost = config.get('DB_HOST_NAME');
var dbPort = config.get('DB_HOST_PORT');

console.log(dbHost); // database.some-dns.example.com
console.log(dbPort); // 6379


// Make changes to .env file
// Say we change the DB_HOST_NAME=anotherhost.com in .env file

config.reload();

var dbHost = config.get('DB_HOST_NAME');

console.log(dbHost); // anotherhost.com

What if you don't have .env file?

You can either:

  • Create a symlink
ln -s path/to/env .env

OR

  • Start the application with config path as such
node yourApp.js --config-path=path/to/env 

Test

npm test
1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago