c0nfig
Require local environment based configs as if they are in
node_modules
.
Install
npm install c0nfig --save
Usage
Create configs for every app environment just putting the env name as prefix of the file name:
app-folder/config:~$ ls -a production.config.jsdevelopment.config.js# etc.
Export some configuration data for every environment like:
// config/development.config.jsmoduleexports = title: 'BLITZKRIEG BOP (STAGING)' apiUrl: 'https://staging.example.org/api';
// config/production.config.jsmoduleexports = title: 'BLITZKRIEG BOP (PRODUCTION)' apiUrl: 'https://example.org/api';
Start your app with proper NODE_ENV
(if not provided it will grab development.config.js
by default), then require/import c0nfig
in your source code and use the data:
// src/app.js;; request;
// src/app.jsconst config = ;const request = ; request;
Template tags
You are able to use template tags like $(configProperty.childProperty)
to point to specific properties of config:
moduleexports = title: 'BLITZKRIEG BOP!' http: port: processenvPORT || 8080 url: processenvURL || 'http://0.0.0.0:$(http.port)' ;
MIT Licensed