message.js 517 B

1234567891011121314151617181920212223
  1. const Joi = require('joi');
  2. const validate = require('./validate');
  3. const schemaSentMessage = Joi.object({
  4. id: Joi.string().required(),
  5. message: Joi.string().min(1).max(1400).required(),
  6. });
  7. module.exports.sentMessage = (req, _res, next) => {
  8. return validate(schemaSentMessage, req.body, next);
  9. };
  10. module.exports.validateUploadFile = (req, res, next) => {
  11. if (!req.file)
  12. return res.status(400).json({
  13. status: 'error',
  14. code: 400,
  15. data: 'Bad request',
  16. message: 'File not found',
  17. });
  18. next();
  19. };