Linking Application Container Cloud to DBaaS – Expose REST API from node.js application leveraging node-oracle-database driver by Lucas Jellema
By Juergenkress-Oracle on May 19, 2016
In a recent article, I discussed the deployment of a simple Node.js application to the Oracle Application Container Cloud. I take this one step further in this article: I extend the node.js application to connect to a DBaaS instance using the Oracle node.js Database Driver and expose a REST API to retrieve data (departments, if you want to know).
This figure illustrates what this article describes:
The steps we go through in this article are:
- Create the Node.js application with node-oracledb based database interaction
- Deploy the Node.js application to Application Container Cloud
- Configure the application on Application Container Cloud: service binding and custom environment variables
- Access the REST API exposed by the Node.js application
- The node-oracledb driver connects node.js applications to an Oracle Database. It is an open source project with Apache 2.0 license. It is maintained by Oracle and is under active development. Sources can be found on GitHub.The node-oracledb driver is available out of the box in a Node.js Application Container Cloud instance. No special steps are required to have access to this driver from a node.js application that is deployed to the Application Container Cloud instance. All you need to do is include the oracledb module in the node.js application (using var oracledb = require(‘oracledb’);) and of course interacting with the database in the regular way supported by node-oracledb.
Create the Node.js application with node-oracledb based database interaction
application is a very simple one. It handles requests – and responds
only in anger to a request that goes like this: http://host:port/departments.
If that is the url – then the relative url is just /departments and
that is what the code responds to in function handleRequest(). When you
check the code in dataApi.js, you will find a few things of notice: Read the complete article here
For regular information become a member in the WebLogic Partner Community please visit: http://www.oracle.com/partners/goto/wls-emea ( OPN account required). If you need support with your account please contact the Oracle Partner Business Center.