common-transport
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

CommonTransport

Common interface for communication between services.

Righ now it only supports AMQP protocol.

Example:

 
//server:
import {CommonTransport} from 'common-transport';
 
let transport = new CommonTransport({
    adapter: 'amqp',
    amqp: {
        host: 'localhost',
        port: 5672,
        user: 'guest',
        pass: 'guest'
    }
});
 
transport.on('products.get' function (params, reply) {
    reply([
        {
            id: 'product-1',
            //....
        }
    ]);
});
 
//client:
import {CommonTransport} from 'common-transport';
 
let transport = new CommonTransport({
    adapter: 'amqp',
    amqp: {
        host: 'localhost',
        port: 5672,
        user: 'guest',
        pass: 'guest'
    }
});
 
(async function () {
    try {
        let products = await transport.call('products.get');
    } catch (err) {
        //an error occured
    }
}());

Readme

Keywords

none

Package Sidebar

Install

npm i common-transport

Weekly Downloads

1

Version

1.1.1

License

ISC

Last publish

Collaborators

  • szymon.wygnanski