GithubHelp home page GithubHelp logo

ranne123 / cloud-cf-helloworld-nodejs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sap-samples/cloud-cf-helloworld-nodejs

0.0 1.0 0.0 103 KB

A "Hello World" application for Cloud Foundry using a simple RESTful API in Node.js with persistency in PostgreSQL and SAPUI5 UIs.

License: Apache License 2.0

JavaScript 100.00%

cloud-cf-helloworld-nodejs's Introduction

Chapter 1: Basic Implementation of a Node.js Web Service

Learning Goal

Having finished this chapter, you should be able to run a small Node.js Web service on your local machine and you'll be able to deploy it to SAP Cloud Platform Cloud Foundry Environment.

Prerequisites

Step 1: Configure NPM on your machine to ensure all subsequent NPM calls work.

Execute the following command:

npm config set @sap:registry https://npm.sap.com

Step 2: Run the service locally.

  • Clone this repo to your machine.  
  • In the folder you cloned into, execute the npm install command.
  • To start the server, execute the nodejs server.js command.
  • To get all users or the details of one user, browse http://<ip>:8088/users or http://<ip>:8088/users/2.
  • To add another entry to the list of users using the POST operation use, for example, the Postman extension of Chrome. (PUT and DELETE are not yet implemented). To test these operations, import the file SAP-CP-CF_Hello_World.postman_collection.json from this repository into Postman.  

Step 3: Push to Cloud and run the service.

To log on, access your endpoint with the following command:

cf api https://api.cf.eu10.hana.ondemand.com

or:

cf api https://api.cf.us10.hana.ondemand.com

(depending upon the landscape your account was created in)
To log on use the following command:

cf login

If you have access to more than 1 org or space, execute the following command:

cf target -o ORG -s SPACE

To deploy the application to SAP Cloud Platform Cloud Foundry Environment, execute the following command:

cf push --random-route

For more information on these commands, see Getting Started with Cloud Foundry and Deploy an Application.

Check the output of this command, and write down the URL created for the application.
As a result you should be able to browse https://<URL for your app>/users.
If you want to use the Postman collection above, please adjust the URL for the requests in the Cloud folder to the allocated <URL for your app>.

cloud-cf-helloworld-nodejs's People

Contributors

ranne123 avatar mariusd7 avatar jonathanbaker7 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.