Skip to content

innotrade/enapso-microservice-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:
```js
generator.open().then(() => {
  // generator is ready for use...
}).catch(console.error);
  1. Generating a micro-service instance (In this case the EnapsoOntology micro-service):
let EOS;
generator.getService('EnapsoOntology').then((response) => {
  EOS = response;
}).catch(console.error);
  1. Then, just invoke some methods (full example here)...
EOS.ontology.list({
  offset: 0,
  length: 50
}).then((response) => {
  console.log(response);
}).catch(console.error);
  1. 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 [email protected]:innotrade/enapso-microservice-client.git
$ cd enapso-microservice-client/
$ npm install
$ npm test

About

HTTP/WebSocket Client (JavaScript) for Enapso Micro-Services

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published