Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vidaxl/config-getter-for-microservices

Package Overview
Dependencies
Maintainers
11
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vidaxl/config-getter-for-microservices

We needed a way to categorize the configuration values to be able to distinguish between them.

  • 0.0.13
  • latest
  • npm
  • Socket score

Version published
Maintainers
11
Created
Source

Configuration getter for some already existing Vidaxl apis

Motivation

We needed a way to categorize the configuration values to be able to distinguish between them.

See below how we did it.

old configuration:

{
  "couchbaseServiceUrl": "http://couchbase-service:3000/v1/couchbase",
  "productCatalogServiceUrl": "http://product-catalog-service:3000/v1/product-catalog",
  "apmServerUrl": "http://10.51.62.67:8200/"
}

new configuration:

{
  "couchbaseServiceUrl": {
    "value": "http://couchbase-service:3000/v1/couchbase",
    "type": "microservice"
  },
  "productCatalogServiceUrl": {
    "value": "http://product-catalog-service:3000/v1/product-catalog",
    "type": "microservice"
  },
  "apmServerUrl": {
    "value": "http://10.51.62.67:8200/",
    "type": "amp"
  }
}

implementing it

I think you see how it goes, it was needed so we can parse out information for the status-aggregator-vidaxl-config-bridge (also part of this monorepo). I tried to make it compatible with the original system in the src/.../helper/config.js:

module.exports = function config() {
    return {
        getConfig: function(field) {
            return server.environment[field];
        }
    };
};

It implemenets the getConfig function, so this library as well, and with the new structure it works compatible. of course value can be any object. Currently the same file mentioned above looks like:

module.exports = require('@vidaxl/config-getter-for-microservices')(server.environment)

It is prepared for better times as the configuration is injectable, and let's hope we willn not always rely on global values, but it works now perfectly.

If you are implementing this library, please make sure that you copy/overwrite the .npmrc file with the one you find in the MICRO-49 branch of the product-catalog-service soon it will be in the master too.

Important

If you are about to update the src/.../helper/config.js of it's kind and implement this library, please make sure that the file does not implements other functions/methods, if so please refactor the code that those functionalities would be the part of another module.

For more details please consult the test.js

FAQs

Package last updated on 28 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc