Skip to content

icebob/moleculer-sidecar-hemera

Repository files navigation

moleculer-sidecar-hemera NPM version

Moleculer <-> Hemera sidecar/gateway.

Features

  • call Hemera service from Moleculer service
  • call Moleculer service from Hemera service
  • emit Moleculer event from Hemera service
  • broadcast Moleculer event from Hemera service

Install

npm install moleculer-sidecar-hemera

Usage

Moleculer side

Call a Hemera service

broker.call("hemera.act", { topic: "math", cmd: "add", a: 5, b: 3 })
    .then(res => broker.logger.info("Result: ", res))
    .catch(err => broker.logger.error(err));

Hemera side

Call a Moleculer service

hemera.act({
    topic: "moleculer",
    cmd: "call",
    action: "greeter.welcome",
    params: {
        name: "John"
    }
}).then(msg => hemera.log.info("Result: ", msg.data))
.catch(err => hemera.log.error(err));

Emit a Moleculer event

hemera.act({
    topic: "moleculer",
    cmd: "emit",
    event: "user.created",
    payload: {
        id: 5,
        name: "John"
    }
    // groups: []
}).catch(err => hemera.log.error(err));

Broadcast a Moleculer event

hemera.act({
    topic: "moleculer",
    cmd: "broadcast",
    event: "user.created",
    payload: {
        id: 5,
        name: "John"
    }
    // groups: []
}).catch(err => hemera.log.error(err));

Settings

Property Type Default Description
natsOptions Object undefined NATS connect options for Hemera.
hemeraOptions Object {} Hemera constructor options.

Test

$ npm test

In development with watching

$ npm run ci

Contribution

Please send pull requests improving the usage and fixing bugs, improving documentation and providing better examples, or providing some testing, because these things are important.

License

The project is available under the MIT license.

Contact

Copyright (c) 2018 MoleculerJS

@icebob @icebob

Releases

No releases published

Packages

No packages published