va-mellower
v1.5.7
Published
logistics for va
Downloads
2
Readme
mellower
logistics is boring
Mock
mock config in your package.json
{
va-mock: {
routes: './mock/routes.js',
config: {
mergeResponse: false
}
}
}routes example, refer to lib/example/xxx.routes.js
[
{
url: 'rest/:tenantid/virtual-agent/intent',
method: 'get',
response: intents,
handler: (ctx, resp) => {
const { query } = ctx;
ctx.body = resp;
if (query.recommended || query.recommended === 'true') {
ctx.body = resp.filter(intent => intent.recommended === true);
}
if (query.name) {
ctx.body = resp.find(item => item.name === query.name);
}
}
}
]handler function arguments:
- ctx is context of your request
- resp is the response property above.
How to use mock in my project
- npm install xxxxx
- update your package.json, add below field:
"va-mock": {
"port": 5000,
"config": {
"mergeResponse": true // tell mocker what to do with your route response and sample route response, if there is existing route in sample.
},
"routeFile": "" // your route definition, json with array of object.
}- run command
va-mock
Validator
currently the validation works for va only.
// you want to validate intent definition
// node.js
const { asyncValidate } = require('@micro-focus/va-mellower');
const intent = {/*some properties*/};
await asyncValidate('Intent', intent, ctx);
// ctx is current request context, such as ctx of KOA or Eggjs
// if you use it in frontend, no need to pass ctx.where to put this mellower package in your package.json
if you just use the mock service, put it in devDependencies
if you use validation, put it in dependencies
release build will only check dependencies
build
- build will happen when commit
- only validation will be built
- mocker is for backend(cjs only) , so no need to build
