Coder Social home page Coder Social logo

janrode / iot-application-services-sdk-nodejs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sap-archive/iot-application-services-sdk-nodejs

0.0 1.0 0.0 57 KB

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

License: Apache License 2.0

JavaScript 100.00%

iot-application-services-sdk-nodejs's Introduction

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.

iot-application-services-sdk-nodejs's People

Contributors

jonathanbaker7 avatar janrode avatar

Watchers

 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.