private room but socketio not ready

This commit is contained in:
vankhaiphan 2021-05-30 20:55:00 +02:00
parent c652958324
commit 36e6596c78
11 changed files with 5019 additions and 0 deletions

View file

@ -0,0 +1,30 @@
const router = require("express").Router();
const Conversation = require("../models/Conversation");
// new conv
router.post("/", async (req, res) => {
const newConversation = new Conversation({
members: [req.body.senderId, req.body.receiverId]
});
try{
const savedConversation = await newConversation.save();
res.status(200).json(savedConversation);
}catch (err){
res.status(500).json(err)
}
});
// get conv
router.get("/:userId", async (req, res) => {
try {
const conversation = await Conversation.find({
members: { $in: [req.params.userId] },
});
res.status(200).json(conversation);
}catch (err){
res.status(500).json(err)
}
})
module.exports = router;