Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member737877
Discoverer

Deploy NodeJS application : No Authentication


Tutorial Overview:

This blog describes the detailed steps required to deploy a basic nodejs application in SAP BTP (earlier know as SAP Cloud Platform) in cloud foundry environment.

This tutorial is divided into two parts:

  1. creating a basic nodejs application

  2. deploying a nodejs application in BTP (Business Technology Platform)


 

Let us create a new directory called : helloworld and navigate inside that directory
commands:

mkdir helloworld
cd helloworld


 

Step1 : Create a new nodejs project
commands:

npm init


It will create a package.json file with the content similar to this:



{
"name": "helloworld",
"version": "1.0.0",
"description": "a simple nodejs application",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "arjun toshniwal",
"license": "ISC"
}



 
Step2 : Install approuter and configure it as a dependency

commands:


npm install @sap/approuter --save


It will add the following tag in package.json file:


{
"dependencies": {
"@sap/approuter": "^10.8.0"
}
}


 
Step3 : Mention approuter as the start script of this nodejs application



"scripts": {
"start": "node node_modules/@sap/approuter/approuter.js"
}


The updated package.json file would look like:




{
"name": "helloworld",
"version": "1.0.0",
"description": "a simple nodejs application",
"dependencies": {
"@sap/approuter": "^10.9.1"
},
"scripts": {
"start": "node node_modules/@sap/approuter/approuter.js"
},
"author": "arjun toshniwal",
"license": "ISC"
}


 
Step4 : Create xs-app.json which is also known as router configuration file in the root directory

commands:


touch xs-app.json


It should contain the following information:

xs-app.json:


{
"welcomeFile": "index.html",
"authenticationMethod": "none"
}


 
Step5 : Create index.html file inside resources directory . This file would serve as a landing page in our application

commands:



mkdir resources
cd resource
touch index.html


index.html :


Hello World


 
Step6 : Create a manifest.yml file which is also known as deployment descriptor file in the root directory of the project

commands:


touch manifest.yml


manifest.yml:


---
applications:
- name: helloworld
random-route: true
buildpack: nodejs_buildpack
memory: 512M



Note: The final package structure looks likes this:



|── helloworld





|  ├── resources

|         ├── index.html

|  ├── package.json

|  ├── xs-app.json





|  ├── manifest.yml



 
Step7 : Login via cf utility

command:

cf login -a <endpoint_url>

where endpoint_url can be found from :




Here it would be,

cf login -a api.cf.eu10.hana.ondemand.com

 
Step8 : Deploy the application into BPT via cf utlitiy:

commands:


cf push





It would give the following output:


where as it can be seen the route of the deployed application is :
helloworld-busy-duiker-qp.cfapps.eu10.hana.ondemand.com


Note:

You can install the cli tools from:https://github.com/cloudfoundry/cli

Goto Download Section to download the cf cli



 
Step 9 : Run the deployed application

4 Comments
Labels in this area