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

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