'use strict' const Joi = require('joi') const pluginConfig = { handlerType: 'profile', docs: { description: 'Returns previously scored profiles', notes: 'returns from the MatchQueue Table', }, } const validators = { params: Joi.object({ profile_id: Joi.number() }), query: Joi.object({ include_profile: Joi.bool() }), } module.exports = { method: 'GET', path: '/{profile_id}/queue', options: { ...pluginConfig.docs, tags: ['api'], /** Protect this route with authentication? */ auth: false, handler: async function (request, h) { const { profile_id } = request.params const { include_profile } = request.query const { profileService, matchQueueService } = request.server.services() const queue = await matchQueueService.getQueue(profile_id) const queueIds = queue.map(entry => entry.target_id) return include_profile ? profileService.getProfilesFor(queueIds) : queueIds }, /** Validate based on validators object */ validate: { ...validators, failAction: 'log', }, // couldn't get validate server response working... /** Validate the server response */ // response: { // schema: Joi.object({ // ok: Joi.bool(), // handler: Joi.string(), // data: Joi.object(), // }), // }, }, }