nats-method-ex-utils
v1.1.0
Published
Utils for nats-method-ex.
Downloads
5
Readme
Nats Method Ex Utils
Utils for nats-method-ex.
About Dependencies
- the only explicit dependency is nats-method-ex.
- if any util needs dependencies, it will receive them from builder args.
Usage
Install
npm install --save nats-method-ex nats-method-ex-utils
Import
const {xxx} = require('nats-method-ex-utils')
Utils
joiInputValidator
const joi = require('joi')
const {
joiInputValidator: validateInput
} = require('nats-method-ex-utils')
methodEx.define('some.method', validateInput(
joi.object({
name: joi.string().required(),
age: joi.number()
}).required()
)(
async (user) => {
...
}
))
extractData
Extract data from response. If response.ok
is false, error will be thrown.
const {extractData} = require('nats-method-ex-utils')
const response = await methodEx.call('xxx')
const data = extractData(response)
License
MIT