1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- 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)
- .patch(
- '/selected/',
- guard,
- validation.removeSelected,
- controllers.removeSelected
- )
- .post(
- '/image/:companionIdAndCaption',
- [guard, upload.uploadImage.single('image'), validation.validateUploadFile],
- controllers.imageMessage
- )
- .post(
- '/audio/:companionIdAndCaption',
- [guard, upload.uploadAudio.single('audio'), validation.validateUploadFile],
- controllers.audioMessage
- )
- .post(
- '/video/:companionIdAndCaption',
- [guard, upload.uploadVideo.single('video'), validation.validateUploadFile],
- controllers.videoMessage
- )
- .post(
- '/file/:companionIdAndCaption',
- [guard, upload.uploadFile.single('file'), validation.validateUploadFile],
- controllers.fileMessage
- );
- router
- .get('/:companionId', guard, controllers.listMessagesById)
- .patch('/pin/:id', guard, controllers.updateMessagePin)
- .patch('/:id', guard, controllers.updateMessageEmoji)
- .delete('/:id', guard, controllers.removeMessage);
- module.exports = router;
|