1.1.0 • Published 7 years ago

enapso-microservice-client v1.1.0

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
7 years ago

Introduction

HTTP/WebSocket Client (JavaScript) for Enapso Micro-Services. This module generate instances from remote micro-services public APIs, benefiting developers with the best possible "easy to use" interface.

Installation

npm install --save enapso-microservice-client

Getting Started

For this example we will use a production installation of the Enapso Enterprise Server, this is the Enapso Dash platform. The library use ES6 Promise based APIs.

  1. Creating the micro-service generator instance:

    const MicroServiceGenerator = require('enapso-microservice-client');
    const generator = new MicroServiceGenerator({
      url: 'https://dash.innotrade.com/http',
      username: 'guest',
      password: 'guest'
    });
    // using WebSocket connection
    const generator = new MicroServiceGenerator({
      url: 'wss://heprdlxdemo01.innotrade.com',
      username: 'guest',
      password: 'guest'
    });
  2. Preparing generator:

    generator.open().then(() => {
      // generator is ready for use...
    }).catch(console.error);
  3. Generating a micro-service instance (In this case the EnapsoOntology micro-service):

    let EOS;
    generator.getService('EnapsoOntology').then((response) => {
      EOS = response;
    }).catch(console.error);
  4. Then, just invoke some methods (full example here)...

    EOS.ontology.list({
      offset: 0,
      length: 50
    }).then((response) => {
      console.log(response);
    }).catch(console.error);
  5. Join all together using a more elegant way, the co library:

    const co = require('co');
    const MicroServiceGenerator = require('enapso-microservice-client');
    const generator = new MicroServiceGenerator({
      url: 'https://dash.innotrade.com/http',
      username: 'guest',
      password: 'guest'
    });
    
    co(function *(){
      // prepare connection
      yield generator.open();
      // generate service
      let EOS = yield generator.getService('EnapsoOntology');
      // call methods...
      let response = yield EOS.ontology.list({
        offset: 0,
        length: 50
      });
    
      //...
      //... finally when all the work is done, close the connection
      yield generator.close();
    })

Config params

let config = {};
config.url = 'https://dash.innotrade.com/http'; // the Enapso Enterprise Server connection URL
config.username = 'guest'; // login username
config.password = 'guest'; // login password
config.autoSyncTimeout = 500; // timeout used by the HttpClient to automatically pull messages from the server. Min value: 400ms

Roadmap

  1. Automated test-cases generation and execution.

Tests

$ git clone git@github.com:innotrade/enapso-microservice-client.git
$ cd enapso-microservice-client/
$ npm install
$ npm test
1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago