'use strict'; const Joi = require('joi'); const pluginConfig = { handlerType: 'user', docs: { get: { description: 'Get user', notes: 'Returns a user item by the id passed in the path' } } } /** Validator functions by request method */ const validators = { get: { params: Joi.object({ name: Joi.string().min(3).max(11), all: Joi.array() }) } } module.exports = { method: 'get', path: '/{name}', handler: async request => { try { /** Get the data for your endpoint */ const { User } = request.models() const all = await User.query() return { ok: true, handler: pluginConfig.handlerType, data: { name: request.params.name, all }, } } catch(err) { return { ok: false, handler: pluginConfig.handlerType, data: { error: err }, } } }, options: { ...pluginConfig.docs.get, tags: ['api'], auth: 'default_jwt', validate: validators.get, response: { schema: Joi.object({ ok: Joi.bool(), handler: Joi.string(), data: validators.get.params }), failAction: 'log' } } }