From 08e54dbcb1847d1d0b93bf60c7e91023e069572d Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Wed, 26 Feb 2025 14:35:42 +0100 Subject: [PATCH] feat+fix: extra endpoints in /class toegevoegd, links in responses naar zuster endpoints toegevoegd --- backend/src/routes/class.ts | 32 ++++++++++++++++++++++++++++++-- backend/src/routes/teacher.ts | 9 +++++---- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/backend/src/routes/class.ts b/backend/src/routes/class.ts index c9fe4259..4d031587 100644 --- a/backend/src/routes/class.ts +++ b/backend/src/routes/class.ts @@ -8,9 +8,37 @@ router.get('/:id', (req, res) => { displayName: 'Klas 4B', teachers: [ '0' ], students: [ '0' ], - assignments: [ '0' ], joinRequests: [ '0' ], - invitations: [ '0' ], + links: { + self: `${req.baseUrl}/${req.params.id}`, + classes: `${req.baseUrl}/${req.params.id}/invitations`, + questions: `${req.baseUrl}/${req.params.id}/assignments`, + students: `${req.baseUrl}/${req.params.id}/students`, + } + }); +}) + +router.get('/:id/invitations', (req, res) => { + res.json({ + invitations: [ + '0' + ], + }); +}) + +router.get('/:id/assignments', (req, res) => { + res.json({ + assignments: [ + '0' + ], + }); +}) + +router.get('/:id/students', (req, res) => { + res.json({ + students: [ + '0' + ], }); }) diff --git a/backend/src/routes/teacher.ts b/backend/src/routes/teacher.ts index 851da986..06ab320b 100644 --- a/backend/src/routes/teacher.ts +++ b/backend/src/routes/teacher.ts @@ -8,10 +8,11 @@ router.get('/:id/', (req, res) => { firstName: 'John', lastName: 'Doe', username: 'JohnDoe1', - endpoints: { - classes: `/teacher/${req.params.id}/classes`, - questions: `/teacher/${req.params.id}/questions`, - invitations: `/teacher/${req.params.id}/invitations`, + links: { + self: `${req.baseUrl}/${req.params.id}`, + classes: `${req.baseUrl}/${req.params.id}/classes`, + questions: `${req.baseUrl}/${req.params.id}/questions`, + invitations: `${req.baseUrl}/${req.params.id}/invitations`, }, }); })