add error checks

This commit is contained in:
Ryahn 2025-01-31 06:27:53 -05:00
parent 9d76a3c45a
commit 06a2c0f0a3

View File

@ -127,11 +127,17 @@ router.use(authenticateToken);
* type: string * type: string
*/ */
router.post('/list', async (req, res) => { router.post('/list', async (req, res) => {
if (!req.body.temp_email_id) {
return res.status(400).json({ error: 'temp_email_id is required' });
}
const messages = await Message.query().where('temp_email_id', req.body.temp_email_id); const messages = await Message.query().where('temp_email_id', req.body.temp_email_id);
res.json(messages); res.json(messages);
}); });
router.post('/read/:id', async (req, res) => { router.post('/read/:id', async (req, res) => {
if (!req.body.id) {
return res.status(400).json({ error: 'id is required' });
}
const message = await Message.query().where('id', req.body.id).withGraphFetched('temp_email').first(); const message = await Message.query().where('id', req.body.id).withGraphFetched('temp_email').first();
res.json(message); res.json(message);
}); });