Configure your NodeJS Application with IBM Cloud App Configuration using nconf-appconfig

Josephinejustin
2 min readMar 13, 2022

Configuration management in applications is the key in the world of micro-services and managing configurations per environment makes it even more complex. Configurations can be managed in a file, in memory, or in a centralized system. IBM Cloud App Configuration is a centralized configuration service in IBM Public Cloud which helps manage your configuration across environments in an easier way.

Why IBM Cloud App Configuration?

Centralized configuration management using IBM Cloud App Configuration provides the following benefits –

  • Managing environment based configurations are easy.
  • Managing global configurations which is common across environments easily as the properties when created are available across all environments
  • Updates to properties does not require any new deployments. Changes are propagated to the applications at real-time.
  • Values can be overridden based on segmentation of users.
  • Configuration as a code can be achieved using github actions
  • Access control can be easily managed per environment.

Configuring your NodeJS Applications using nconf-appconfig

You can configure your NodeJS applications using variety of npm packages. If you are using nconf already in your application, you can easily update your code to use nconf-appconfig npm package to pull properties from IBM Cloud App Configuration service instance.

App Configuration can be initialized using the nconf.use function as below –

Initialize nconf-appconfig

nconf.get can be used to retrieve the property value when the entity id is passed. Following is the code snippet to retrieve the property value from app configuration

get property using nconf-appconfig

A sample application using nconf-appconfig is available here.

Summary

IBM Cloud App Configuration provides an easy way to maintain the centralized configurations. nconf-appconfig npm package helps easily adopt the code from nconf to externalize the configurations to App Configuration.

Resources

--

--