Skip to main content

Create Micro CRUD services for Oracle Database Cloud using NodeJS

I will try to explain, how you can use NodeJS to create mirco services for the tables in your Oracle Database Cloud or on-premise Database.

Complete Github project : https://github.com/sohamda/LeasifyAPIs
You need to do "npm install" to download the node_modules.

Step by Step guide :

1. NodeJS : either 32 or 64 bit.

If you already have NodeJS installed, please check whether it is 64 or 32. Use below command to figure that out :
C:\>node
> require('os').arch()

If you get : 'ia32' , then it is 32 bit installation.

2. Install oracle-db node module

This was a lengthy and time consuming installation for me, because for Windows, it has a lot of pre-requisites. If you are a Mac user, you are lucky. :)
I followed : https://community.oracle.com/docs/DOC-931127
There is also a detailed one in github : https://github.com/oracle/node-oracledb/blob/master/INSTALL.md

3. Config your DB Cloud

Create a user and couple of tables on which we'll write the Microservices.
I created an user with some basic GRANTS


 



Connected to the DB instance via SQL Developer and created 2 tables :



Now we gonna write some CRUD services on both the tables.

4. Lets explain my NodeJS code

This tutorial from Oracle is excellent for starters : http://www.oracle.com/webfolder/technetwork/tutorials/obe/cloud/apaas/node-cloud-REST-DB/nodecloud-RESTDB.html#overview
You should go through it once before you try to understand my NodeJS construction.

JS code:
4i. app.js : Creates a NodeJS server and invokes "./routes/index.js" for REST URI "/" and "./routes/users.js" for URI "/users". All our DB cloud api is in "index.js"
4ii. ./routes/index.js : Defines an API catalogue on "/api/catalogue" and micro services on LEASE_HISTORY and USERS table.
4iii. ./routes/users_crud.js : Defines the CRUD methods for USERS table.
4iv. ./routes/lease_crud.js : Defines the CRUD methods for LEASE_HISTORY table.
4v.  ./routes/dbutil.js : Defines common utility methods for DB operations.



Config files:
4i. manifest.json : Defines the Application Container Cloud NodeJS version and command to start this NodeJS applicaiton. You only need this file if you want to deploy this application to Oracle Application Container Cloud, Otherwise not.
4ii. package.json : Defines application name, command and dependencies.

5. Running this locally:

Run it from command line :



Check in Postman :



6. Upload it in Application Container Cloud :

Follow the next blog on this.







Comments

  1. Developing better communication skills is important for every individual in society. It gives us the chance to express our thoughts and to share our own views about various aspects. It is also the source of building confidence.motivation letter for college

    ReplyDelete
  2. very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information about the web design and web development.Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.
    Hire Nodejs Developers
    Nodejs Development Company

    ReplyDelete
  3. Thank you for sharing this info. it will be helpful for our Database Development Services.
    Database Development Services
    Database Development

    ReplyDelete
  4. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer Node js Training in Chennai . learn from or Javascript Online Training from India. Nowadays JavaScript has tons of job opportunities on various vertical industry. JavaScript Training in Chennai

    ReplyDelete
  5. Thanks For sharing nice article about database development services.
    Database Development Services in India

    ReplyDelete
  6. Great informational resource as always!I really love the way of explaining this post.You are just outstanding...Keep posting more
    node.js development services

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. I really like your article. You’ve mentioned steps which can be easily understood.You have explained everything very clearly.Iam much more impressed.the person who created this post is a genius and knows how to keep the readers connected.If anyone needs any clarifation ,please have a look on https://yiioverflow.com/

    ReplyDelete
  9. It is very good blog and useful for students

    Oracle SOA Online Course

    ReplyDelete

Post a Comment

Popular posts from this blog

Secure your Node/Express REST APIs using Passport JS

Recently I have been involved in various discussions on how to make the REST APIs as secure as SOAP.
First of all, let me start with a very basic statement, about security, it doesn't depend on your Webservice type, be it REST or SOAP, your design decisions depicts whether they can be made secure or not.
In this example blog, I will use "Micro CRUD services for Oracle Database Cloud" APIs and implement (read attach) Passport's "local" authentication strategy, to make them secure.

Code in Github : LeasifyAPIs with Passport

What is Passport JS? (from Documentation)

Passport is authentication middleware for Node. It is designed to serve a singular purpose: authenticate requests. When writing modules, encapsulation is a virtue, so Passport delegates all other functionality to the application. This separation of concerns keeps code clean and maintainable, and makes Passport extremely easy to integrate into an application.

What are "strategies" in P…

ADF Utility : Find UIComponent from Managed Bean

Many a times, it is required to find an UIComponent from ADF managed bean, to do something with it, for example : change the value of an af:outputText, change readOnly property of an af:inputText etc.

private UIComponent getUIComponent(String id) { 

        FacesContext facesCtx = FacesContext.getCurrentInstance(); 
        return findComponent(facesCtx.getViewRoot(), id);
    } 

    private UIComponent findComponent(UIComponent base, String id) {

        if (id.equals(base.getId())) {
            return base;
        }

        UIComponent children = null;
        UIComponent result = null;
        Iterator childrens = base.getFacetsAndChildren();
        while (childrens.hasNext() && (result == null)) {
            children = (UIComponent)childrens.next();
            if (id.equals(children.getId())) {
                result = children;
                break;
            }
            result = findComponent(children, id);
            if (result != null) {
                break;
            }
  …

Chatbots and Oracle Cloud Services

Thanks to Oracle A-Team, I had a chance to work with Chatbots.
3 pure NodeJS applications, on couple of Oracle Cloud platforms and Facebook messenger, and my chatbot was running.

Let me explain, the architecture a bit. To start with, following is the simple representation of how it works.