hemera-parambulator
v1.0.1
Published
This is a plugin to use Parambulator with Hemera
Downloads
12
Readme
Hemera-parambulator package
This is a plugin to use Parambulator with Hemera.
We prefer to use Joi as a payload validator. The status quo of payload validation in NodeJs.
Example
const Hemera = require('./../')
const nats = require('nats').connect()
const hemera = new Hemera(nats, {
logLevel: 'info'
})
hemera.use(require('hemera-parambulator'))
hemera.ready(() => {
// Use Parambulator as payload validator
hemera.setOption('payloadValidator', 'hemera-parambulator')
/**
* Your Implementations
*/
hemera.add({
topic: 'math',
cmd: 'add',
a: {
type$: 'number'
}
}, (req, cb) => {
cb(null, req.a + req.b)
})
hemera.act({
topic: 'math',
cmd: 'add',
a: 'dwed3',
b: 20
}, function (err, resp) {
this.log.info('Error', err)
})
})
Pass the full schema
hemera.add({
topic: 'email',
cmd: 'send',
pb$: {
a: {
type$: 'number'
}
}
}, (resp, cb) => {
})