Like the previous exercises, you will start by creating a new module. New->Node.js Module
Name the module core_xsjs
and press Next.
Be sure to check the box Enable XSJS support. Then press Next. Then press Finish.
Once again the mta.yaml
file has been extended to add the core_xsjs
module.
This XSJS module will also need the UAA service for authentication. Additionally, it will need data from the database module and the HDI container behind it. Add those dependencies to the node module
Now you need to add the dependency from the web module to this new Node.js module and a destination route to it as well.
In the Requires
section of the web module, add core_xsjs-api
If you are editing this manually, this should match the name of the value under Provides
in the new node module
Add destinations
in the field group and the following key-value pairs as the properties for the core_xsjs-api
module:
name: core-backend
url: ~{url}
forwardAuthToken: true
The complete section for the web module should now look like this:
What is this configuration for?
The approuter
is a module that serves as a single point of entry to a Multi-Target Application. In this case, the web module contains the call to this module in the package.json
file. The approuter
will use routes to determine the destination for a request coming from, for example, a web browser. The configuration you have just entered is naming the Node.js destination as core-backend
, URL is picking up the value from the provides
URL, which is in turn taking it from the reserved environment variable, default-url
.
Later at deploy, the destination routing builds a dependency and navigation ability between the two services without ever having to hard code the URLs or ports. They are assigned at deploy time and all references are automatically updated.
Save the yaml
file and go into the code editor. Copy the definition of the node module in the validation below: