Skip to content
Snippets Groups Projects
Commit 21111b59 authored by Moreau Elise's avatar Moreau Elise
Browse files

[api][messages routes] remove mongoose & send user instead of his id

parent 3070f5c9
No related branches found
No related tags found
No related merge requests found
import express from 'express'; import express from 'express';
import mongoose from "mongoose";
const router = express.Router(); const router = express.Router();
import Room from "../models/Room.js"; import Room from "../models/Room.js";
...@@ -35,7 +34,7 @@ router.post('/', validator.body(messageSchema), async function(req, res, next){ ...@@ -35,7 +34,7 @@ router.post('/', validator.body(messageSchema), async function(req, res, next){
const newMessage = new Message({ const newMessage = new Message({
body: req.body.body, body: req.body.body,
author : author._id, author: author,
room: room._id, room: room._id,
date: new Date() date: new Date()
}); });
...@@ -46,10 +45,6 @@ router.post('/', validator.body(messageSchema), async function(req, res, next){ ...@@ -46,10 +45,6 @@ router.post('/', validator.body(messageSchema), async function(req, res, next){
return next(err); return next(err);
} }
// websockets.forEach(function (otherWS) {
// otherWS.send(JSON.stringify(msg))
// });
res.json(newMessage); res.json(newMessage);
}) })
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment