Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. 'use strict'
  2. const Joi = require('joi')
  3. const pluginConfig = {
  4. handlerType: 'profile',
  5. docs: {
  6. description: 'Returns previously scored profiles',
  7. notes: 'returns from the MatchQueue Table',
  8. },
  9. }
  10. const validators = {
  11. params: Joi.object({ profile_id: Joi.number() }),
  12. query: Joi.object({ include_profile: Joi.bool() }),
  13. }
  14. module.exports = {
  15. method: 'GET',
  16. path: '/{profile_id}/queue',
  17. options: {
  18. ...pluginConfig.docs,
  19. tags: ['api'],
  20. /** Protect this route with authentication? */
  21. auth: false,
  22. handler: async function (request, h) {
  23. const { profile_id } = request.params
  24. const { include_profile } = request.query
  25. const { profileService, matchQueueService } =
  26. request.server.services()
  27. const queue = await matchQueueService.getQueue(profile_id)
  28. const queueIds = queue.map(entry => entry.target_id)
  29. return include_profile
  30. ? profileService.getProfilesFor(queueIds)
  31. : queueIds
  32. },
  33. /** Validate based on validators object */
  34. validate: {
  35. ...validators,
  36. failAction: 'log',
  37. },
  38. // couldn't get validate server response working...
  39. /** Validate the server response */
  40. // response: {
  41. // schema: Joi.object({
  42. // ok: Joi.bool(),
  43. // handler: Joi.string(),
  44. // data: Joi.object(),
  45. // }),
  46. // },
  47. },
  48. }