add posting comments

This commit is contained in:
Michael Fatemi 2021-04-11 14:14:22 -04:00
parent 43a0317a3b
commit 94143bc4fa

View File

@ -5,6 +5,26 @@ import requireApiAuth from '../requireApiAuth';
export const router = Router(); export const router = Router();
router.post('/:poolID/comment', requireApiAuth, async (req, res) => {
const userID = req.session.accountID;
const poolID = req.params.poolID;
const commentBody = req.body.body;
await PoolModel.updateOne(
{ _id: poolID },
{
$push: {
comments: {
author_id: userID,
body: commentBody,
},
},
}
).exec();
res.json({ status: 'success' });
});
router.post('/:poolID/join', async (req, res) => { router.post('/:poolID/join', async (req, res) => {
const userID = req.session.accountID; const userID = req.session.accountID;
const poolID = req.params.poolID; const poolID = req.params.poolID;