minor import changes

This commit is contained in:
Moon Patel
2023-07-02 17:56:28 +05:30
parent 9ec5021dea
commit cfd207e41f
5 changed files with 18 additions and 14 deletions
+12 -10
View File
@@ -3,24 +3,26 @@ const uuid = require("uuid");
const { createRoom } = require("../socket");
const { sendEmail } = require("../mail");
const { User } = require("../models/user");
const { checkAuth } = require("../util/auth");
// rooms can only be created through HTTP requests and destroyed only by socket.io server
// and vice versan is not true
router.post("/create", async (req, res, next) => {
// and vice versa is not true
router.post("/create", checkAuth, async (req, res, next) => {
console.log(req.body);
// challenger and challenged are username
const { challenger, challenged } = req.body;
const challengedEmail = await User.findOne({ username: challenged }).email;
const challengedEmail = (await User.findOne({ username: challenged })).email;
console.log(challengedEmail);
const roomID = uuid.v4();
createRoom(roomID, req.body.timeLimit);
sendEmail(
challengedEmail,
`Challenge from ${challenger}`,
`To accept the challenge follow the link: http://192.168.136.99:5173/game/challenges/${challenged}/${roomID} \n login through: http://192.168.136.99:5173/login \n roomid:${roomID}`
);
// sendEmail(
// challengedEmail,
// `Challenge from ${challenger}`,
// `To accept the challenge follow the link: http://192.168.136.99:5173/game/challenges/${challenged}/${roomID} \n login through: http://192.168.136.99:5173/login \n roomid:${roomID}`
// );
res.json({ roomID });
});