Since Node.js became available on z/OS, mainframe developers have adopted this popular programming platform to rapidly build applications such as web servers servicing API endpoints, caching layers that buffer data access to the mainframe as well as, micro services driving transactions in the backend. This blog dives into how Node.js enables developers to easily orchestrate data across different API services.
Business requirements dictate the definition of APIs; Typically, these APIs do not directly correspond to the existing back-end data and transactions needed to support them. Thus, similar to a dance with different dance moves that need to be choreographed, the API implementation is broken down to multiple tasks that need to be orchestrated.
For example, an API implementation may poll data from VSAM datasets to feed into IMS transactions, that in turn triggers external API calls to augment the data into the desired results. Like specific dance moves, multiple services and data resources are often invoked, while business logic orchestrates the flow and sequence.
To better understand the API orchestration, let’s consider the scenario depicted in Figure 1 below. Using Node.js, we can create an application that provides an external endpoint (API) to request information about a particular person. The application accepts the name of the person as an input parameter and returns the corresponding phone number, city and state info. In its implementation, the Node.js application performs this task in two phases. First, it connects to an existing phonebook application on IMS TM using z/OS Connect, to retrieve the phone number and zip code. Then, it accesses the public cloud API (/api.zippopotam.us/country/postal) to retrieve the city and state information and augment the zipcode data. The combined results are then returned to the user as a JSON response.
Believe it or not, the entire Node.js application can be accomplished in < 50 lines of code! Check out the Node.js application code (courtesy of Yves Tolod) here. On that site you will also find an additional sample of Node.js application as orchestrator using z/OS Connect EE to access CICS TM with Db2.