1.0.13 • Published 6 years ago

babex-node v1.0.13

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

About

Babex is a modern solution for communications between microservices.

Versions

Version 1

Input message:

{
  "data": Any,
  "chain": [Path],
  "config": Any
}

Where Path like:

{
  "exchange": String,
  "key": String,
  "isMultiple": Bool,
  "successful": Bool
}

Example

Service example Sum(a, b):

Request:

{
  "data": {
    "a": 2, 
    "b": 3
  },
  "chain": [
    {
      "exchange": "math",
      "key": "math.sum",
      "isMultiple": false
    },
    {
      "exchange": "math",
      "key": "sum.next",
      "isMultiple": false
    }
  ],
  "config": null
}
const babex = require('babex-node');
const exchange = 'math';
const routingKey = 'math.sum';
const config = babex.config;
config.name = 'math.sum';
config.address = process.env.RMQ_ADDRESS;

babex
    .newService(config)
    .then((service) => service
        .bindToExchange(exchange, routingKey)
        .then((service) => service
            .listen((message) => {
                let payload = {
                    c: message.data.a + message.data.b
                };
                
                service.next(message, payload);
            })
        )
    )
    .catch(console.warn);

Result:

{
  "data": {
    "c": 5
  },
  "chain": [
    {
      "exchange": "math",
      "key": "sum",
      "isMultiple": false,
      "successful": true
    },
    {
      "exchange": "math",
      "key": "sum.next",
      "isMultiple": false,
      "successful": false
    }
  ],
  "config": null
}
1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

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