1.4.6 • Published 3 years ago

@bitninja/ninjarpc v1.4.6

Weekly downloads
14
License
MIT
Repository
bitbucket
Last release
3 years ago

BitNinjaIO NinjaRPC

RabbitMQ rpc server and client by BitNinja.io based on PHP implementation

Installation

Using npm:

$ npm i @bitninja/ninjarpc

Usage

The package contains a client and a server as well, which can communicated each other.

Server

// Load the package
const NinjaRpcServer = require("@bitninja/ninjarpc").NinjaRpcServer;

// Create a new server
const server = new NinjaRpcServer({
  hostname: "127.0.0.1",
  username: "guest",
  password: "guest",
  port: 5672,
  vhost: "/"
});

// List of endpoints, keys are the endpoints
// values are callback functions
const endpoints = {
  endpoint1: endpoint1
};

// Example endpoint
function endpoint1(params) {
  console.log(`Endpoint 1 was called with ${params} parameters.`);
}

// Server listens on the given endpoints
server.listen("TEST_SERVICE", endpoints);

Client

// Load the client package
const NinjaRpcClient = require("@bitninja/ninjarpc").NinjaRpcClient;

// Create a client
const client = new NinjaRpcClient({
  hostname: "127.0.0.1",
  username: "guest",
  password: "guest",
  port: 5672,
  vhost: "/"
});

// Simply just call an endpoint
client.call("TEST_SERVICE", "endpoint1", { customattr: "customValue" });
1.4.6

3 years ago

1.4.5

4 years ago

1.4.3

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago