diff --git a/src/api/pool.ts b/src/api/pool.ts index 0e88dec..f94b3d1 100644 --- a/src/api/pool.ts +++ b/src/api/pool.ts @@ -5,6 +5,26 @@ import requireApiAuth from '../requireApiAuth'; 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) => { const userID = req.session.accountID; const poolID = req.params.poolID;