Skip to content

Simple NodeJS Application, and make it runing on the SAP Business Technology Platform Cloud Foundry Enviroment

License

Notifications You must be signed in to change notification settings

seyaFly/SAPBTP_NODE_VUE_SIMPLE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

English | 中文

Table Of Content

Preparation

BTP Account

Use this link to apply and setup the BTP trial or enterpise enviroment

Tools

Nodejs

Install and setup Nodejs.

IDE

we can use the VSC as you favourite development IDE, or other IDE you like.

CF Command line

Dowanload and Configration : Download and Install the Cloud Foundry Command Line Interface

Direct Download link: https://github.com/cloudfoundry/cli#downloads

Development

Steps:

  1. Install the vue cli via the command : npm install -g @vue/cli

  2. create vue project via the command : vue ui or vue create my-project

  3. add dev and prod mode envrioment variable for multiple development mode under root folder

    vueDevMode

    fileName: .env.dev

      NODE_ENV = 'dev'
      VUE_APP_PORT=3000
    

    fileName: .env.prod

      NODE_ENV = 'prod'
      VUE_APP_PORT=80
    
  4. add vue.config.js

vueDevMode

and here is the example code :

   var env = process.env.NODE_ENV;
   var bdisaBleHostCheck = false;
   let evnPort = process.env.PORT;

   if (env === "dev") {
       evnPort = 3000;
       bdisaBleHostCheck = false
   } else {
       bdisaBleHostCheck = true;
   }

   module.exports = {
       devServer: {
           port: evnPort,
           disableHostCheck: bdisaBleHostCheck
       }
   }

Test(local)

Run Vue project with command line npm run serve

Test it with the link : http://localhost:8080/#

and then get this page .

vueProjectWelcome

After that , the nodejs applciation is working fine

Deployment

Deploy for BTP:

  1. set cloud foundry endpoint via command :

    cf api {EndpointURL}

    EndpointURL you can find in your subaccount : APIEndPoint

  2. login to your BTP endpoint with your btp user and password command :

    cf login

  3. add manifest.yml for CF BTP development

    manifest

  4. configure the route and nodejs buildpacks

here we suggest use bellow format as recomendation :

  {subdomain}-{appname}.{cfappdoman}

subdomain:

subdomain

appname: defined by business

cfappsdomain: user the command cf domains to get the domain url

cfappdomain

Example:

 ---
 applications:
 - name: nodejsapp
   command: npm run serve
   memory: 400M
   path: btpnodejs
   buildpacks: 
     - nodejs_buildpack
   routes: 
       - route: 91ccc175trial-nodejsapp.cfapps.ap21.hana.ondemand.com 
  1. Deploy your nodjs project to your BTP Subaccount

    command :

    cf push

Test(BTP subaccount)

  1. Navigte to your space

space

  1. Go you applcation

space_application

  1. Get applicaiton URL

applicationOverview

  1. Test it with the URL

    {applicaitonURL}/#/
    

    After get the below response, then your nodejs application is working fine

    applciationWelcome

Refrence

Create and Deploy Your First Node.js App: btp-nodejs-deploy

Vue JS guide : VueJs Guide

About

Simple NodeJS Application, and make it runing on the SAP Business Technology Platform Cloud Foundry Enviroment

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published