Skip to content

A NodeJS package that acts as a thin wrapper over the API of SAP IoT Application Enablement.

License

Notifications You must be signed in to change notification settings

maxstreifeneder/iot-application-services-sdk-nodejs

 
 

Repository files navigation

SAP IoT Application Enablement SDK for Node.js

Table of Contents

Description

A Node.js package that acts as a thin wrapper over the API of SAP IoT Application Enablement (SAP IoT AE).

Requirements

Expected SAP software:

  • SAP IoT Application Enablement

Other requirements:

Download and Installation

The following guide helps you to create a simple node-application which accesses data stored in SAP IoT AE.

1. Generate a node.js application:

Create a new folder called node-wrapper-demo. Start the command prompt in this folder, execute npm init and follow the instructions. When finished you should find a file called package.json in the folder.

2. Install the NodeWrapper:

Next, we add the NodeWrapper as a dependency to our node-application. For this purpose, add the following section to the package.json:

{
  ...
  "dependencies": {
    "iot-application-services-sdk-nodejs": "SAP/iot-application-services-sdk-nodejs"
  },
  ...
}

Afterwards, go back to your command promit and execute npm install. This will install all dependencies specified in the package.json.

3. Configuration:

Next, we have to configure our NodeWrapper. Add a file called .env to the root of our project and add the following content:

AE_OAUTH_CLIENT_ID=<your client-id goes here>
AE_OAUTH_CLIENT_SECRET=<your client-secret goes here>
AE_TENANT=sap-iotaehandson
AE_LANDSCAPE=eu10
AE_HOST=hana.ondemand.com

4. Usage:

Now we create the main part of our application, which calls the API of SAP IoT AE. Create a file called index.js in the root of the project. Copy and paste the following code to this file:

var NodeAE = require('iot-application-services-sdk-nodejs')
var nodeAE = new NodeAE()

// set the base URI for the NodeWrapper
nodeAE.setBaseURI('appiot-mds') // 'appiot-mds' = the app of the API we will use in the following

// now we can use plain http methods to send requests (post, get, put, delete)
var loadingThings = nodeAE.get('/Things')
loadingThings.then(
  function success (oResponse) {
    console.log(JSON.parse(oResponse.body)) // will print all Things on the console
  },
  function error (err) {
    throw err
  }
)

Now you can start the application. Enjoy!

Hint: If you would like to see what is happening in the background, you can enable the logging to console via set DEBUG=ae_nodewrapper:*.

Known Issues

NA

How to obtain support

Please create an issue within this GitHub repsitory.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Lint and test your code using npm test.

We use Semantic Versioning. For the versions available, see the tags on this repository.

To-Do (upcoming changes)

NA

License

Copyright (c) 2017 SAP SE or an SAP affiliate company. All rights reserved.

This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file.

About

A NodeJS package that acts as a thin wrapper over the API of SAP IoT Application Enablement.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%