You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

leave.js 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. 'use strict'
  2. const Joi = require('joi')
  3. const pluginConfig = {
  4. handlerType: 'grouping',
  5. docs: {
  6. description: 'leave',
  7. notes: 'Leave a grouping by creating a membership record',
  8. },
  9. }
  10. const validators = {
  11. leave: {
  12. payload: Joi.object(),
  13. },
  14. }
  15. module.exports = {
  16. method: 'POST',
  17. path: '/leave',
  18. options: {
  19. ...pluginConfig.docs,
  20. tags: ['api'],
  21. auth: false,
  22. handler: async function (request, h) {
  23. try {
  24. return {
  25. ok: true,
  26. handler: pluginConfig.handlerType,
  27. data: { foo: 'bar' },
  28. }
  29. } catch (err) {
  30. return {
  31. ok: false,
  32. handler: pluginConfig.handlerType,
  33. data: { error: `${err}` },
  34. }
  35. }
  36. },
  37. validate: validators.leave,
  38. response: {
  39. schema: Joi.object({
  40. ok: Joi.bool(),
  41. handler: Joi.string(),
  42. data: validators.leave,
  43. }),
  44. failAction: 'log',
  45. },
  46. },
  47. }