FeedHenry Instance URL
Retrieves the URL of an MBaaS Service or Cloud Application in the FeedHenry platform.
In the example below we get a URL for our MBaaS, then make a request to get some data it exposes.
var fhurl = ;fhurl;
The target environment is determined by matching it with the current env, so a DEV Node.js Cloud Application will get the DEV Service URL if making a call using this module. This uses process.env.FH_ENV under the hood.
Developing locally is defined as running your application with the FH_USE_LOCAL_DB environment variable set to "true", or not having FH_MILLICORE or FH_ENV set since these are always set in RHMAP containers.
When developing locally this module will first check for the existence of an fhconfig.json file in the root of your project directory to resolve the provided guid for the lookup to a URL of your choosing. More details for this fhconfig JSON file are provided below. If you'd rather use FH_SERVICE_MAP which is the default for $fh.service lookups that will work so long as you do not have an fhconfig.json file in your project root.
If no mappings are provided i.e FH_SERVICE_MAP is not defined and fhconfig.json is not present, we will attempt to use the Red Hat Mobile APIs to resolve the URL (this is what happens when code is deployed on RHAMP). To do this you must set the following environment variables locally:
These variables can be found in a the Environment Variables tab of your Cloud Application.
Get the URL for a service based on the passed GUID or params. Params can be a String (the GUID), or an object with the properties guid and domain.
Returns an object containing headers required to make a service request. You can merge this with another Object to make a finalised headers Object with your headers plus RHMAP headers.
The fhconfig.json is a general configuration file we can use to manage local development when using fh-instance-url.
Here's a sample:
And a description of the keys:
The domain your application is/will run on.
Contains keys (guids of apps) that manage MBaaS Service interaction.
Contains information related to specific MBaaS components identified by their, AppID or GUID.
A name you might assign to identify an MBaaS. Does not have to match the name in the RHMAP Studio.
Used to point MBaaS requests to a custom host during local development.
- 1.1.0 - Add improved trace logging for debugging support. Reduce install size by limiting files included in package.
- 1.0.0 - Introduce fhconfig.json support. Rewrite module and improve testing.
- 0.X.Y - Here be dragons
No strict guidelines. Just run the tests before making a pull request, and add new ones if required. You can run tests by cloning locally and running npm test in the project directory.