@nib/nconf-transforms

0.1.0 • Public • Published

nconf-transforms

Similar to .NET web.config transforms, nconf-transforms allows you to load nconf configuration files based on convention. By default reads the NODE_ENV environment variable to select what config file to transform. Currently only supports JSON format.

Usage

require('nconf').argv().env() // don't forget to load your environment/argv variables if you want them!

var transform = require('nconf-transforms');

transform({
  dir: './config',
  reload: true // reload nconf when the config file changes
  format: require('nconf-yaml')
});

where your file tree is something like

/app
  app.js
  /config
    settings.json
    settings.production.json

settings.json

{
  "someConfig": "someValue"
}

app.js

var nconf = require('nconf');
console.log(nconf.get('someConfig')); // "someValue"

API

transform(options)

Loads your base configuration and transforms it using the NODE_ENV environment variable to find the transform file.

Options:

  • dir: String. The directory to find the configuration files. Defaults to __dirname, so set it anyway.
  • fileName: String. The name of your configuration files (i.e settings.json, settings.production.json). Defaults to settings
  • reload: Boolean. Toggles reloading of configuration when the base config changes.
  • environment: String. The environment to transform to. Defaults to process.env['NODE_ENV']
  • format: String. The nconf file format to use. Defaults to JSON.

Returns the nconf object so you can chain loading other configuration types/files.

Readme

Keywords

none

Package Sidebar

Install

npm i @nib/nconf-transforms

Weekly Downloads

3

Version

0.1.0

License

none

Last publish

Collaborators

  • aschofield-nib
  • ian.darroch
  • syed.husain
  • nib-admin
  • lauriejones
  • cmayson
  • ken-ky-wong
  • stribs
  • wng-services
  • eastwood
  • elias.tran.nib
  • fiona.wang
  • mattbourke
  • sameer-e-digio
  • nathan.ford-nib
  • narcher
  • tmcclenahan
  • samjwillis-nib
  • varindernib
  • tristancampbellmb
  • nib-nz-build
  • sarahyapnib
  • c.rhind
  • vaanim
  • tgoldthorpe-nib
  • akash.prakash
  • nib-build-agent
  • anandmampuzhakal
  • jackmennienib
  • dariasu
  • bennettsolnet
  • airfan
  • thomasc42
  • rovacsek
  • gnguyennib
  • tom.mok
  • shane-w
  • tbrown-nib
  • vicvinegar
  • oshan.kottege
  • xiaoxinghu
  • harshahr1994
  • rbowen006
  • seanw.nib
  • anishmat27
  • sean0x42
  • zander-mudbath
  • sbeliak-nib
  • stephen.wong
  • amir.rudd
  • c.lassen
  • dimi7ri
  • dmitrymatveev
  • vaishalibhakhar
  • alejop-mudbath
  • r3gm1
  • maraza1721
  • d-martin-nib
  • apnib
  • kieranjogrady
  • siyengar94
  • dsmitham
  • msikkema
  • johanjarvi
  • vivien_clifford_nib
  • brad.turner
  • amy.tait.nib
  • scottwalkerau
  • jnwest
  • s.hossain
  • billthomas-nib
  • mleontieff
  • alunarzewski
  • bendharvey
  • tjodzio-nib
  • tarantoj
  • tejaswikota
  • julie.li
  • pallavi.barna
  • danieltran-nib
  • mitchellharrold
  • damodaran
  • caleb.faith
  • connorpmcbride
  • kemila-nib
  • pmv-npm
  • dermotosullivannib
  • xunsavior
  • aiswaryarajendran
  • shirleyshao
  • chris.close.nib
  • dguilbert
  • blakehattingh
  • samreedy
  • anylyne
  • georgia.batson
  • johnpaulvaughan
  • georgia-batson
  • john.hartmann.nib
  • trentontws
  • juliexxvi
  • davetapsonnib
  • joshua.coleiro
  • williamgonzaleznib
  • amelialuwia
  • dluong.mud
  • rgstephens
  • daron.robinson
  • aadams-rasa
  • eddylj
  • chaulagainajeet
  • joshgermon-nib
  • parisa.heyd
  • bencoll
  • indira.ramachandra
  • s.bista
  • nnattawat
  • ash-tulett-nib
  • sylvia.zh
  • nathanpiper-nib
  • neon-inkblast
  • karlb_nz
  • saranya-nibtravel
  • sdarshy
  • darcymerrickmudbath
  • abilioh
  • smdabrar
  • terencesunendava
  • digio-shanefitzgerald
  • paul-neville-thompson
  • adamgonlag
  • zainab.saif
  • cooldesignluke
  • krut
  • daniel-nib
  • swaff-y
  • zi_choong
  • domcorso-nib
  • jbayer
  • sheren
  • jezz-jon
  • csfrank-nib
  • artem.shkumat
  • nathananstess.nib
  • steevtee
  • nadeeth-nib1
  • anandmenon
  • dlegaspi-nib
  • wstolp
  • brettalcorn
  • ts1654
  • davidvnib
  • nmaffioldnib
  • sumo_nib
  • mthamyeeznib
  • csol94
  • brodee
  • jmatas
  • nib-vish
  • reallandal
  • phil.a.hawkins
  • tkemp
  • rasberghout
  • kim-mckenna-endava
  • xhua026
  • sachin.patil79
  • sam-jacobson
  • dean-nib
  • nicknguyennib2
  • l.lourenco
  • fe_nib
  • satkaur
  • tom-endava
  • sobitha
  • paritoshdhebar_endava
  • nib-daniel
  • vinualwisnib
  • sanjaydholakiya.nibtravel
  • lguan
  • bradley.williams
  • sannat-digar
  • gaurijadhav
  • mgw114
  • alankirknibtravel
  • ruilunli
  • pkernaghan
  • adamwitanowski-nib
  • dominic-cheung-nib
  • thomas.austin.nib
  • luke.morrissey
  • yparulkar-nib
  • reddevilmancnpm