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

choosematch.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. 'use strict'
  2. const Joi = require('joi')
  3. const pluginConfig = {
  4. handlerType: 'matchque',
  5. docs: {
  6. description: 'updates matchque',
  7. notes: 'Updates MatchQue Table if User chooses to match with another or chooses to delete match',
  8. },
  9. }
  10. const validators = {
  11. // /** Validate the header (cookie check) */
  12. // // headers: true,
  13. // /** Validate the route params (/active/{thing}) */
  14. params: Joi.object({ profile_id: Joi.number() }),
  15. // /** Validate the route query (/active/{thing}?limit=10&offset=10) */
  16. // // query: true,
  17. // /** Validate the incoming payload (POST method) */
  18. payload: Joi.object({
  19. profile_id_2: Joi.number(),
  20. reinsert: Joi.boolean(),
  21. }),
  22. }
  23. module.exports = {
  24. method: 'POST',
  25. path: '/{profile_id}/choose',
  26. options: {
  27. ...pluginConfig.docs,
  28. tags: ['api'],
  29. /** Protect this route with authentication? */
  30. auth: false,
  31. handler: async function (request, h) {
  32. const { profile_id } = request.params
  33. const { profile_id_2, reinsert } = request.payload
  34. const { matchQueService } = request.server.services()
  35. return await matchQueService.markAsDeleted(
  36. profile_id,
  37. profile_id_2,
  38. reinsert,
  39. )
  40. },
  41. /** Validate based on validators object */
  42. validate: {
  43. ...validators,
  44. failAction: 'log',
  45. },
  46. // couldn't get validate server response working...
  47. /** Validate the server response */
  48. // response: {
  49. // schema: Joi.object({
  50. // ok: Joi.bool(),
  51. // handler: Joi.string(),
  52. // data: Joi.object(),
  53. // }),
  54. // },
  55. },
  56. }