@microservice-framework/microservice-client
Client Interface for microservice-framework
Last updated 2 years ago by microservice-framework .
GPL-3.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @microservice-framework/microservice-client 
SYNC missed versions from official npm registry.

microservice-client

Gitter npm microservice-frame.work

Microservice framework client.

On webBrowser level is possible to use AJAX and WebSocket. See examples here.

    <script src="http://microservice-frame.work/js/microservice-client.min.js"></script>
    <script>
$(function() {    
    var clientSettings = {
      URL: "wss://apiserver.com/ws_endpoint/",
      token: 'secureKey or AccessToken'
    }
    ws = new MicroserviceWebSocket(clientSettings);
    ws.on('message', function(object){
      console.log(object);
    });
});
    </script>
    <script src="http://microservice-frame.work/js/microservice-client.min.js"></script>
    <script>
$(function() {    
    var clientSettings = {
      URL: "https://apiserver.com/service",
      secureKey: 'ServiceSecureKey'
    }
    client = new MicroserviceClient(clientSettings);
    client.search({}, function(err, handlerResponse){
      if(err){
        return $('#result').html(err);
      }
      $('#result').html(JSON.stringify(handlerResponse, null, 2));
    });
});

$(function() {    
    var clientSettings = {
      URL: "https://apiserver.com",
      secureKey: 'ServiceSecureKey'
    }
    client = new MicroserviceClient(clientSettings);
    client.search('endpoint', {}, function(err, handlerResponse){
      if(err){
        return $('#result').html(err);
      }
      $('#result').html(JSON.stringify(handlerResponse, null, 2));
    });
});
    </script>

Nodejs:

'use strict';

const MicroserviceClient = require('@microservice-framework/microservice-client');

require('dotenv').config();

var client = new MicroserviceClient({
  URL: "http://localhost:" + process.env.PORT,
  secureKey: process.env.SECURE_KEY
});

var RecordID;
var RecordToken;

client.post({
    name: "Microservice",
    data: {
      value: test
    }
  }, function(err, handlerResponse){
    console.log(handlerResponse);
    RecordID = handlerResponse.id;
    RecordToken = handlerResponse.token;
    
    client.search({
      name: "Microservice"
      }, function(err, handlerResponse){
        console.log(handlerResponse);
    });
    
    client.get(RecordID, RecordToken, function(err, handlerResponse){
      console.log(handlerResponse);
    });
    
    client.put(RecordID, RecordToken, {
      extra: {
        extravalue: "test2"
      }
    }, function(err, handlerResponse){
      console.log(handlerResponse);
    });
    
    client.delete(RecordID, RecordToken, function(err, handlerResponse){
      console.log(handlerResponse);
    });
});

Changelog

  • 1.2.5
    • added nodejs package name to UserAgent
    • fixed URL variable
    • added support for API based requests
  • 1.3.0
    • switch to 'Access-Token' instead of 'access_token'
    • support new validation for microservices
  • 1.3.1
    • prevent autoset User-Agent if package linked by browser
  • 1.3.2
    • replace const with var for uglify compatibility.
  • 1.3.3
    • allow to replace header 'Accept'
  • 1.3.4
    • fix error when parse empty response as JSON.

Current Tags

  • 1.3.4                                ...           latest (2 years ago)

15 Versions

  • 1.3.4                                ...           2 years ago
  • 1.3.3                                ...           2 years ago
  • 1.3.2                                ...           2 years ago
  • 1.3.0                                ...           2 years ago
  • 1.2.5                                ...           2 years ago
  • 1.2.4                                ...           3 years ago
  • 1.2.3                                ...           3 years ago
  • 1.2.2                                ...           3 years ago
  • 1.2.1                                ...           3 years ago
  • 1.2.0                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 6
Last Day 0
Last Week 2
Last Month 7
Dependencies (5)
Dev Dependencies (3)

Copyright 2014 - 2016 © taobao.org |