Skip to Content
Technical Articles
Author's profile photo Sabarna Chatterjee

Create API in NodeJS using SAP API Management

Here is a small demonstration on how to use SAP API Managment Service to design your API and deploy it in SAP Cloud Foundry.

Coding Lang – NodeJS

Cloud Platform – SAP Cloud Platform ( Neo Environment – API Development | CF Environment – API Deployment)

Source code editor: VS Code

CF CLI used – https://github.com/cloudfoundry/cli/wiki/V7-CLI-Installation-Guide

Below methods have been followed:

  1. API Structure is designed in SCP API Management service.
  2. Development of the API done locally in a windows desktop.
  3. Deployed the API in the SCP CF account.

 

Git Link – API Management

 

Step 1: Go to API Management service and click on Access API Designer.

The below URL will be opened.

API%20Designer%20screen

API Designer screen

 

Step 2: Update this YAML file according to the requirement. In my scenario I have updated the file as – swagger yaml file

 

Step 3: Click on the highlighted option and give the details in the corresponding fields. Then update the project metadata.

 

Step 4: Get VS Code installed and open the folder in the workspace. Your project will look like below:

Open%20the%20project%20from%20VS%20Code

Open the project from VS Code

 

Step 5: Time to write some command scripts:

A. now Click on Terminal and execute the command “npm Install”:

after%20npm%20install%20is%20executed

after npm install is executed

 

B. Execute – “npm install random-number”

 

npm%20install%20random-number

npm install random-number

 

 

C. Execute – “npm start”

 

npm%20start

npm start

 

“Dear reader, Please let me know on how to remove these vulnerabilities. ?”

Local server will run at: http://localhost:8080/docs

Next thing is my favourite. To see the docs in Swagger. It will appear as below:

local%20host

localhost:8080

 

Note the below things if you are new to NodeJS-

  1. Its very huge – handle with care
  2. try to use Nodemon – ( Sounds Similar to Pokemon)
  3. try to use EJS

Any Ways, lets move on.

 

Step 5: Update the file – Default.js from the git-url: Default.js

Note – according to your requirement change this section.

Then redeploy the API and test the API:

 

Step 6: Now lets deploy this.

Update manifest.yml from the url: https://github.com/sabarna17/SCP_API_Management/blob/master/manifest.yml

 

Install CF7 from the below url:

https://packages.cloudfoundry.org/stable?release=windows64&version=v7&source=github

  • Once installed, goto cmd and use the below code to login to

cf7 login -a https://api.cf.eu10.hana.ondemand.com -u {loginid} -p {password} -o {orgName}

 

cf7 push -f manifest.yml

 

Cloud API is now deployed.

Login to the SCP CF to see the latest deployed API.

Your%20Space%20-%20Application%20-%20Overview

Your Space – Application – Overview

 

Your API is on cloud now. Enjoy testing it. I havn’t shown the steps related to use the API keys. It can be incorporated as per your requirement.

— Thanks for reading. Please do leave a comment if any changes are required.

 

 

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.