Chapter 6. Web

6.1. npm

npm is the package manager for distributing JavaScript code. It is used to install the RHMAP JavaScript SDK for developing Cordova apps.

6.1.1. Installing Node.js and npm

You must have Node.js installed on your system to use npm. It is recommended that you install NodeJS version 4.x or later, which includes npm version 2.x by default.

6.1.1.1. Install Node.js Using a Package Manager

To install Node.js using your system package manager, follow the instructions appropriate for your system on the Node.js site

To check the version of npm you are currently using, execute the following command:

sudo npm -v

6.1.2. Installing Node.js and npm on Red Hat Enterprise Linux

To install NodeJS on systems running RHEL, you must obtain the installation files from the Red Hat Software Collections. Installing NodeJS requires a subscription to the Red Hat Subscription Manager.

To install NodeJS on RHEL, follow the guide on the Red Hat Developers Portal.

6.2. Introduction

This is a Node.js + Express web application. These apps provide more advanced desktop/tablet web portals and mobile websites.

They expose the full power of Node.js for web app development including functionality such as Express 4 and server side templating using template engines such as ejs.

They also support static file serving for standard HTML5, CSS and JavaScript.

6.3. New App

Download the sample app to get started with a new Web App which has the RHMAP SDK already included.

6.4. Existing App

Web Apps apps use our standard JavaScript SDK — included in the index.html file.

6.4.1. Download SDK

Note

fh-js-sdk is distributed using npm. To be able to complete the steps below, you must install npm.

  1. In the /public folder of your app project, open the package.json file and add the latest version of fh-js-sdk onto the list of dependencies:

      "dependencies": {
        "fh-js-sdk": "^2.17.5",
      }
  2. In the root folder of your app, execute the following command to install the SDK:

    sudo npm install fh-js-sdk

    This installs the SDK version specified in the dependencies in the package.json file

6.4.2. Integrate SDK

Add the following code to your index.html file.

<head>
  <script src="feedhenry.js" type="text/javascript"></script>
</head>

6.4.3. Set up Configuration

Create a new file in the same directory as the SDK file (feedhenry.js) called fhconfig.json, with the following contents:

{
  "appid": "__ID_OF_APP_IN_PROJECT__",
  "appkey": "__APP_API_KEY_OF_APP_IN_PROJECT__",
  "connectiontag": "__CONNECTION_TAG_TO_USE_FOR_CLOUD__",
  "host": "__APP_STUDIO_HOST__",
  "projectid": "__PROJECT_ID__"
}

More information on connections can be found here.

6.5. Use SDK

See API Docs for full details on the APIs available within the SDK.