Add validateParticipantID to participant routes

This commit is contained in:
2020-05-11 00:25:08 +02:00
parent 7a0b2b09ba
commit 03815bd2f6
2 changed files with 36 additions and 3 deletions

View File

@@ -0,0 +1,26 @@
const Participant = require('../api/models/participantModel');
async function validateParticipantID(req, res, next) {
const { account_id, meeting_id } = req.params;
try {
const participant = await Participant.getParticipantById(
account_id,
meeting_id,
);
if (typeof participant == 'undefined') {
res.status(404).json({
message: `Participant with id ${id} doesn't exist.`,
});
} else {
next();
}
} catch (error) {
res.status(500).json({
message: `Failed to get participant with id ${account_id}-${meeting_id}.`,
error,
});
}
}
exports.validateParticipantID = validateParticipantID;