We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 22235ee + b5767ec commit aabfee3Copy full SHA for aabfee3
controller/group.js
@@ -5,12 +5,20 @@ import {
5
updateGroupById,
6
} from "#services/group";
7
import { logger } from "#util";
8
+import { isEntityIdValid } from "#middleware/entityIdValidation";
9
+import Student from '#models/student';
10
11
async function addGroup(req, res) {
12
const { title, student } = req.body;
13
+ const isStudentValid = await isEntityIdValid(student, Student);
14
try {
15
+ if(isStudentValid){
16
const group = await createGroup(title, student);
17
res.json({ res: `added group ${group.id}`, id: group.id });
18
+ }
19
+ else{
20
+ res.status(400).json({err: "Invalid Id"});
21
22
} catch (error) {
23
logger.error("Error while inserting", error);
24
res.status(500);
0 commit comments