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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. opts: {
  11. tags: ['api'],
  12. auth: { strategy: 'default_jwt' },
  13. cors: true,
  14. },
  15. }
  16. const validators = {
  17. leave: {
  18. payload: Joi.object(),
  19. },
  20. }
  21. module.exports = {
  22. method: 'POST',
  23. path: '/leave',
  24. options: {
  25. ...pluginConfig.docs,
  26. ...pluginConfig.opts,
  27. handler: async function (request, h) {
  28. try {
  29. return {
  30. ok: true,
  31. handler: pluginConfig.handlerType,
  32. data: { foo: 'bar' },
  33. }
  34. } catch (err) {
  35. return {
  36. ok: false,
  37. handler: pluginConfig.handlerType,
  38. data: { error: `${err}` },
  39. }
  40. }
  41. },
  42. validate: validators.leave,
  43. response: {
  44. schema: apiSchema.single.append({
  45. data: validators.leave,
  46. }),
  47. failAction: 'log',
  48. },
  49. },
  50. }