21 lines
735 B
JavaScript
21 lines
735 B
JavaScript
|
import customError from '../response/customError.js';
|
||
|
import responseCodes from '../response/responseCodes.js';
|
||
|
import GroupService from '../services/group.js';
|
||
|
|
||
|
const groupExists = async (req, res, next) => {
|
||
|
let groupId = req.params.groupId || req.body.groupId;
|
||
|
|
||
|
let group = await GroupService.getById(groupId);
|
||
|
|
||
|
if (!group) throw new customError(`group does not exists`, responseCodes.responses.groups.id_not_found);
|
||
|
next();
|
||
|
};
|
||
|
|
||
|
const localIdExists = async (req, res, next) => {
|
||
|
let localId = req.params.localId || req.body.localId;
|
||
|
|
||
|
if (!localId) throw new customError(`local id is not specified`, responseCodes.responses.general.invalid_syntax);
|
||
|
next();
|
||
|
}
|
||
|
|
||
|
export default { groupExists, localIdExists }
|