messages.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. const express = require('express');
  2. const router = express.Router();
  3. const guard = require('../helpers/guard');
  4. const controllers = require('../controllers/messages');
  5. const validation = require('../validation/message');
  6. const upload = require('../helpers/upload');
  7. router
  8. .get('/', guard, controllers.listMessages)
  9. .post('/', guard, validation.sentMessage, controllers.sentMessage)
  10. .post(
  11. '/image/:companionId',
  12. [guard, upload.uploadImage.single('image'), validation.validateUploadFile],
  13. controllers.imageMessage
  14. )
  15. .post(
  16. '/audio/:companionId',
  17. [guard, upload.uploadAudio.single('audio')],
  18. controllers.audioMessage
  19. )
  20. .post(
  21. '/video/:companionId',
  22. [guard, upload.uploadVideo.single('video'), validation.validateUploadFile],
  23. controllers.videoMessage
  24. )
  25. .post(
  26. '/file/:companionId',
  27. [guard, upload.uploadFile.single('file'), validation.validateUploadFile],
  28. controllers.fileMessage
  29. );
  30. router
  31. .get('/:companionId', guard, controllers.listMessagesById)
  32. .delete('/:id', guard, controllers.removeMessage);
  33. module.exports = router;