const express = require('express'); const router = express.Router(); const guard = require('../helpers/guard'); const controllers = require('../controllers/messages'); const validation = require('../validation/message'); const upload = require('../helpers/upload'); router .get('/', guard, controllers.listMessages) .post('/', guard, validation.sentMessage, controllers.sentMessage) .post( '/image/:companionId', [guard, upload.uploadImage.single('image'), validation.validateUploadFile], controllers.imageMessage ) .post( '/audio/:companionId', [guard, upload.uploadAudio.single('audio'), validation.validateUploadFile], controllers.audioMessage ) .post( '/video/:companionId', [guard, upload.uploadVideo.single('video'), validation.validateUploadFile], controllers.videoMessage ) .post( '/file/:companionId', [guard, upload.uploadFile.single('file'), validation.validateUploadFile], controllers.fileMessage ); router .get('/:companionId', guard, controllers.listMessagesById) .delete('/:id', guard, controllers.removeMessage); module.exports = router;