bluemix-config
v0.1.1
Published
a module to help manage the configuration of bluemix project
Downloads
1
Readme
docplexcloud-config
The configuration module for docplexcloud
Build
npm run build
Test
npm run test
Usage
- Create a bluemix.config.js file in your project
module.exports = {
// vcap_application
application: {},
// vcap_services
services: {
"user-provided": [
{
credentials: {
url: "http://localhost:9080/service_url"
},
syslog_drain_url: "",
label: "user-provided",
name: "service_name",
tags: []
}
]
},
// other environment variable here
env: {
TEST_ENV: '12345678'
}
}
- Create a config file
config.js
// return a config instance
const Config = require('bluemix-config');
return new Config('project path');
- get a vcap service
If VCAP_SERVICES is not defined, the value defined in bluemix.config.js will be returned
// require your config file
const config = require('your config.js');
// get vcap environment
const vcapEnv = config.getVcapEnv();
// get services
const services = vcapEnv.getServices();
// get service
const service = vcapEnv.getService(spec);
// get service url
const servcieURL = vcapEnv.getServiceURL(spec, replacements)
// get service credentials
const credential = vcapEnv.getServiceCreds(spec)
The function signature can be found at cfenv
- get a environment variable from environment
If environment variable is not defined, the value defined in bluemix.config.js will be returned
const config = require('your config.js');
const nodeEnv = config.getEnv('NODE_ENV');