Skip to content

Instantly share code, notes, and snippets.

@FelipeBarrosCruz
Last active March 1, 2018 19:22
Show Gist options
  • Save FelipeBarrosCruz/3cecab82bbe730d75ea7e3201882dcae to your computer and use it in GitHub Desktop.
Save FelipeBarrosCruz/3cecab82bbe730d75ea7e3201882dcae to your computer and use it in GitHub Desktop.
function Plugin () {
const seneca = this
const MergeValidate = require('btime-merge-validate-package')
const mergeValidate = MergeValidate(seneca)
const PICK_FIELDS = [
'field'
]
seneca.add({ role: 'plugin', cmd: 'create' }, cmd_create)
function cmd_create (args, done) {
mergeValidate.validate({
args,
pick: PICK_FIELDS,
schema: getValidateSchema(),
options: { abortEarly: false }
})
.then(params => create(params))
.then(result => done(null, result))
.catch(err => done(null, err))
}
function createService(params) {
return new Promise((resolve, reject) => {
return reject({ status: false, message: 'Error' })
return resolve({ status: true, result: {} })
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment