const Joi = require('joi') const pluginConfig = { handlerType: 'user', docs: { get: { description: 'get user', notes: 'Returns a user by the email passed in the path', }, }, } const validators = { params: Joi.object({ user_email: Joi.string() }), } module.exports = { method: 'GET', path: '/{user_email}', options: { ...pluginConfig.docs.get, tags: ['api'], // auth: 'default_jwt', auth: false, cors: true, handler: async (request, h) => { try { const { userService } = request.services() const email = request.params.user_email const user = await userService.findByEmail(email) return { ok: true, handler: pluginConfig.handlerType, data: { user }, } } catch (err) { return { ok: false, handler: pluginConfig.handlerType, data: { error: err }, } } }, validate: { ...validators, failAction: 'log', }, response: { schema: Joi.object({ ok: Joi.bool(), handler: Joi.string(), data: Joi.object(), }).label('password_res'), failAction: 'log', }, }, }