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.

Node.js has several advantages that contribute to its success as a performant API orchestrator. As APIs are often bottlenecked by I/O operations and back-end services, Node.js’s asynchronous, event-driven model allows its applications to efficiently scale to handle large number of concurrent transactions. Built upon the popular JavaScript language, developers can seamlessly integrate JavaScript objects with JSON, the compact data-exchange format used in many RESTful APIs. Finally, the modular nature of Node.js applications enables developers to rapidly assemble their applications, and share/reuse modules across different micro services.

z/OS Connect EE is today the premier gateway to your z/OS transactional assets, by exposing them as REST APIs. In the past, if you needed to develop higher level applications that tie multiple z/OS services together, you often had to build this logic in COBOL and run it as a new transaction within CICS / IMS. Nowadays, Node.js presents a very appealing and more developer friendly alternative for these scenarios – build a Node.js application that invokes the z/OS Connect EE APIs for existing transactions, develop the business logic in JavaScript, and manage the new API with z/OS Connect EE. Bootstrap your Node.js applications by using the zosconnect-node npm module to auto discover and access your z/OS Connect APIs, or the loopback-connector-zosconnectee npm module to connect your LoopBack (open-source Node.js API framework) applications to z/OS Connect APIs.

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.

API Orchestration with Node.js on z/OS
Figure 1: Example to API Orchestration with Node.js on z/OS

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.

And that’s really it! Now it’s your turn to give Node.js a try!
To download IBM SDK for Node.js on z/OS click here.
To try out Node.js on z/OS at no cost on the IBM Z Trial program click here.

Join The Discussion

Your email address will not be published. Required fields are marked *