Install and Configure the Oracle Mobile Hub Tooling for Deploying Custom APIs

You can download and configure additional tools to deploy custom APIs in Oracle Mobile Hub.

Install the Node.js Tooling

When you download the SDK from Oracle Technology Network (OTN), you have the option to download the omce-tools-vXX.X.X file, which includes a Node.js script that you can use to deploy your applications to Oracle Mobile Hub

To install the Node.js tooling in your project:

  1. Download the omce-tools-vXX.X.X zip file and uncompress the Zip file into a directory
  2. On your machine, open a terminal window (It might be necessary to run this command as an admin user), and then change to the omce-tools/node-configurations directory.
  3. Determine the Node configuration that you need to use for the custom API that you are testing. Use 6.10 for Node version 6.10.0 or compatible, and use 8.9 for Node version 8.9.4 or compatible. The default Node configuration for Oracle Mobile Hub is 8.9.
  4. Change to the directory for the node configuration that you want to use: either `6.10` or `8.9`
  5. Run the following command:
    npm install
  6. Change to the omce-tools directory.
  7. Run the command:
    npm install -g

    This command makes the tooling available globally in your local environment. You need to have Node.js and the npm package manager installed before running this command

  8. Set the environment variable NODE_PATH to the node_modules directory for the node configuration you want to use or to path/omce-tools/node-configurations/8.9/node_modules.
  9. To test if the installation was successful, run the command:
    omce-test --version

Download a JavaScript Scaffold for a Custom API

After you create your custom API, you can download a scaffold that is based on your API's RAML document, and then use the scaffold as a quick start for implementing your custom API.

The scaffold comes in the form of a Node module, the key components of which are the main JavaScript file that contains stub methods for each endpoint (resource plus HTTP method), and a package.json file, which serves as the manifest for the module.

To download the scaffold:

  1. Click This is an image of the sidebar menu. to open the side menu, click Development , and then click APIs.
  2. Open the API that you want to download.
  3. In the left navigation area of the API Designer, click Implementations.
  4. Click JavaScript Scaffold to download the zip file.
  5. On your system, unzip the downloaded file.

If you later change the API, then you can download a new scaffold based on the updated endpoints. However, any coding that you may have done and uploaded previously won’t be reflected in the new scaffold.

Configure the toolsConfig.json File

After you have downloaded a scaffold file that is based on your API's RAML document, you can manually configure a JavaScript Notation (JSON) file called toolsConfig.json.

Oracle Mobile Hub uses a toolsConfig.json file that contains the deployment information for a custom API. A default toolsConfig.json is generated when you create a custom API, and you download the scaffold. To configure the toolsConfig.json file:

  1. Open the mobile backend Settings page in Oracle Mobile Hub
  2. Note the information in the Settings page.
    The Settings page contains information like the types of authentication (HTTP Basic, OAuth Consumer), and the Environment URLs.
  3. Using a text editor, update the toolsConfig.json file with the values from the Settings page in Oracle Mobile Hub.
        "backend":{
            "backendId":"<YOUR_BACKEND_ID>",
            "backendName":"<YOUR_BACKEND_NAME>",
            "backendVersion":"<YOUR_BACKEND_VERSION>",
            "authorization":{
                "anonymousKey":"<BACKEND_ANONYMOUS_KEY>",
                "clientId":"<BACKEND_CLIENT_ID>",
                "clientSecret":"<BACKEND_CLIENT_SECRET>"
            }
        },
  4. Open the Development page.
  5. Click Instance Details.
  6. Note the Team Member App Client Id and Team Member App Client Secret values.
  7. Update your toolsConfig.json file with these values.
        "tools":{
            ...,
            "authorization":{
                "clientId":"<TEAM_MEMBER_APP_CLIENT_ID>",
                "clientSecret":"<TEAM_MEMBER_APP_CLIENT_SECRET>"
            }
        },
  8. (Optional) To test that the toolsConfig.json is correct you can do a deployment test. Open a terminal window, navigate to the omce-tools directory and deploy the custom API using the command:
    node omce-deploy toolsConfig.json
    After you run this command, you are prompted for your Oracle Mobile Hub credentials. If your toolsConfig.json file is correct, a message that says Deployment completed successfully is displayed. You can use this command to deploy your custom API in the future.