@pager/minion-joi

Joi validation for pager/minion workers


Keywords
microservices, rabbitmq, workers, json
License
MIT
Install
npm install @pager/minion-joi@1.1.0

Documentation

Minion-joiJoi validation for pager/minion workers

Usage Example

const validation = require('minion-joi')

const validator = validation(Joi.object({
    foo: Joi.string().required()
}))

const handler = (message) => {
   return `Hello ${message.foo}`
}

module.exports = validator(handler)

By default minion will nack and not requeue messages on failure, if you want the message to be requeued after failing validation you can do it like this:

const validation = require('minion-joi')

const validator = validation(Joi.object({
    foo: Joi.string().required()
}), { requeue: false })

const handler = (message) => {
   return `Hello ${message.foo}`
}

module.exports = validator(handler)