BenefitJS base on koa.js, running in v8 runtime.
[![standard][standard-image]][standard-url]
const props = {
id: Joi.number().integer().description('id'),
phone: Joi.string().description('phone'),
password: Joi.string().description('password')
}
const schema = Joi.object().keys(props).description('user info')
index: {
path: '/users',
method: 'get',
tags: ['users'],
summary: 'get users list',
query: _.pick(props, ['phone']),
output: {
200: Joi.object().keys({
result: Joi.array().items(props).description('users list')
})
}
}
create: {
path: '/users',
method: 'post',
tags: ['users'],
summary: 'create user',
requestBody: {
body: _.pick(props, ['phone', 'password']),
required: ['phone', 'password']
},
output: {
200: Joi.object().keys(props).description('result')
}
}
show: {
path: '/users/:id',
method: 'get',
tags: ['users'],
summary: 'get user',
params: _.pick(props, ['id']),
output: {
200: Joi.object().keys(props).description('result')
}
}
update: {
path: '/users/{id}',
method: 'put',
tags: ['users'],
summary: 'update user',
params: _.pick(props, ['id']),
requestBody: {
body: _.pick(props, ['phone'])
},
output: {
200: Joi.array().items(Joi.number()).descript('result')
}
}
destroy: {
path: '/users/{id}',
method: 'put',
tags: ['users'],
summary: 'destroy user',
params: _.pick(props, ['id']),
output: {
200: Joi.number().descript('result')
}
}
[standard-image]: https://cdn.rawgit.com/standard/standard/master/badge.svg [standard-url]: https://github.com/standard/standard