12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- 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('/reply/', guard, validation.sentMessage, controllers.sentMessageReply)
- .post(
- '/forward/',
- guard,
- validation.sentForwardMessage,
- controllers.sentMessageForward
- )
- .patch(
- '/selected/',
- guard,
- validation.removeSelected,
- controllers.removeSelected
- )
- .patch('/unpin/all/', guard, validation.unpinAll, controllers.unpinAllMessage)
- .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;
|