From f45a9aa5a5980c6b59a99726095217edfea847f0 Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Tue, 25 Feb 2025 11:03:00 +0100 Subject: [PATCH 01/13] map routers gemaakt met router files in, backend/src/app.ts bevat verwijzingen naar deze files met app.use --- backend/src/app.ts | 18 ++++++++++++++++++ backend/src/routes/assignment.ts | 9 +++++++++ backend/src/routes/class.ts | 9 +++++++++ backend/src/routes/group.ts | 14 ++++++++++++++ backend/src/routes/login.ts | 9 +++++++++ backend/src/routes/question.ts | 9 +++++++++ backend/src/routes/student.ts | 25 +++++++++++++++++++++++++ backend/src/routes/submission.ts | 9 +++++++++ backend/src/routes/themes.ts | 10 ++++++++++ 9 files changed, 112 insertions(+) create mode 100644 backend/src/routes/assignment.ts create mode 100644 backend/src/routes/class.ts create mode 100644 backend/src/routes/group.ts create mode 100644 backend/src/routes/login.ts create mode 100644 backend/src/routes/question.ts create mode 100644 backend/src/routes/student.ts create mode 100644 backend/src/routes/submission.ts create mode 100644 backend/src/routes/themes.ts diff --git a/backend/src/app.ts b/backend/src/app.ts index 65dd8a7a..532f7734 100644 --- a/backend/src/app.ts +++ b/backend/src/app.ts @@ -1,9 +1,18 @@ import express, { Express, Response } from 'express'; import initORM from './orm.js'; +import studentRouter from './routes/student'; +import groupRouter from './routes/group'; +import assignmentRouter from './routes/assignment'; +import submissionRouter from './routes/submission'; +import classRouter from './routes/class'; +import questionRouter from './routes/question'; +import loginRouter from './routes/login'; + const app: Express = express(); const port: string | number = process.env.PORT || 3000; + // TODO Replace with Express routes app.get('/', (_, res: Response) => { res.json({ @@ -11,6 +20,15 @@ app.get('/', (_, res: Response) => { }); }); +app.use('/student', studentRouter); +app.use('/group', groupRouter); +app.use('/assignment', assignmentRouter); +app.use('/submission', submissionRouter); +app.use('/class', classRouter); +app.use('/question', questionRouter); +app.use('/login', loginRouter); + + async function startServer() { await initORM(); diff --git a/backend/src/routes/assignment.ts b/backend/src/routes/assignment.ts new file mode 100644 index 00000000..0a3b4c02 --- /dev/null +++ b/backend/src/routes/assignment.ts @@ -0,0 +1,9 @@ +import express from 'express' +const router = express.Router(); + +// information about an assignment with id 'id' +router.get('/:id', (req, res) => { + res.send('assignment'); +}) + +export default router \ No newline at end of file diff --git a/backend/src/routes/class.ts b/backend/src/routes/class.ts new file mode 100644 index 00000000..746e8662 --- /dev/null +++ b/backend/src/routes/class.ts @@ -0,0 +1,9 @@ +import express from 'express' +const router = express.Router(); + +// information about an class with id 'id' +router.get('/:id', (req, res) => { + res.send('class'); +}) + +export default router \ No newline at end of file diff --git a/backend/src/routes/group.ts b/backend/src/routes/group.ts new file mode 100644 index 00000000..87e8e6ee --- /dev/null +++ b/backend/src/routes/group.ts @@ -0,0 +1,14 @@ +import express from 'express' +const router = express.Router(); + +// information about a group (members, ... [TODO DOC]) +router.get('/:id', (req, res) => { + res.send('group'); +}) + +// the list of questions a group has made +router.get('/:id/questions', (req, res) => { + res.send('questions'); +}) + +export default router \ No newline at end of file diff --git a/backend/src/routes/login.ts b/backend/src/routes/login.ts new file mode 100644 index 00000000..691a860c --- /dev/null +++ b/backend/src/routes/login.ts @@ -0,0 +1,9 @@ +import express from 'express' +const router = express.Router(); + +// returns login paths for IDP +router.get('/', (req, res) => { + res.send('login route'); +}) + +export default router \ No newline at end of file diff --git a/backend/src/routes/question.ts b/backend/src/routes/question.ts new file mode 100644 index 00000000..1de0ae42 --- /dev/null +++ b/backend/src/routes/question.ts @@ -0,0 +1,9 @@ +import express from 'express' +const router = express.Router(); + +// information about an question with id 'id' +router.get('/:id', (req, res) => { + res.send('question'); +}) + +export default router \ No newline at end of file diff --git a/backend/src/routes/student.ts b/backend/src/routes/student.ts new file mode 100644 index 00000000..151b050f --- /dev/null +++ b/backend/src/routes/student.ts @@ -0,0 +1,25 @@ +import express from 'express' +const router = express.Router(); + +// the list of classes a student is in +router.get('/:id/classes', (req, res) => { + res.send('classes'); +}) + +// the list of submissions a student has made +router.get('/:id/submissions', (req, res) => { + res.send('submissions'); +}) + + +// the list of assignments a student has +router.get('/:id/assignments', (req, res) => { + res.send('assignments'); +}) + +// the list of groups a student is in +router.get('/:id/group', (req, res) => { + res.send('groups'); +}) + +export default router \ No newline at end of file diff --git a/backend/src/routes/submission.ts b/backend/src/routes/submission.ts new file mode 100644 index 00000000..dbec9c8b --- /dev/null +++ b/backend/src/routes/submission.ts @@ -0,0 +1,9 @@ +import express from 'express' +const router = express.Router(); + +// information about an submission with id 'id' +router.get('/:id', (req, res) => { + res.send('submission'); +}) + +export default router \ No newline at end of file diff --git a/backend/src/routes/themes.ts b/backend/src/routes/themes.ts new file mode 100644 index 00000000..99f4dd0c --- /dev/null +++ b/backend/src/routes/themes.ts @@ -0,0 +1,10 @@ +import express from 'express' +const router = express.Router(); + +// I'm not sure what's supposed to be here +// https://github.com/SELab-2/Dwengo-1/issues/24 +router.get('/', (req, res) => { + res.send('themes route'); +}) + +export default router \ No newline at end of file From deb5d772cbcdf46e8593e80ce384705f87c8648d Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Tue, 25 Feb 2025 11:04:52 +0100 Subject: [PATCH 02/13] pad suffixen in routes/student.ts en routes/group.ts veranderd naar enkelvoud --- backend/src/routes/group.ts | 2 +- backend/src/routes/student.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/routes/group.ts b/backend/src/routes/group.ts index 87e8e6ee..36e0be6e 100644 --- a/backend/src/routes/group.ts +++ b/backend/src/routes/group.ts @@ -7,7 +7,7 @@ router.get('/:id', (req, res) => { }) // the list of questions a group has made -router.get('/:id/questions', (req, res) => { +router.get('/:id/question', (req, res) => { res.send('questions'); }) diff --git a/backend/src/routes/student.ts b/backend/src/routes/student.ts index 151b050f..55582992 100644 --- a/backend/src/routes/student.ts +++ b/backend/src/routes/student.ts @@ -2,18 +2,18 @@ import express from 'express' const router = express.Router(); // the list of classes a student is in -router.get('/:id/classes', (req, res) => { +router.get('/:id/class', (req, res) => { res.send('classes'); }) // the list of submissions a student has made -router.get('/:id/submissions', (req, res) => { +router.get('/:id/submission', (req, res) => { res.send('submissions'); }) // the list of assignments a student has -router.get('/:id/assignments', (req, res) => { +router.get('/:id/assignment', (req, res) => { res.send('assignments'); }) From 16b8ab368b48d2cf850f287d9f1d8f02334a3441 Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Tue, 25 Feb 2025 12:27:57 +0100 Subject: [PATCH 03/13] databank verbinding in app.ts uitgezet, dummy json bodies toegevoegd in verschillende routes --- backend/package.json | 7 ++++--- backend/src/app.ts | 4 ++-- backend/src/routes/assignment.ts | 9 ++++++++- backend/src/routes/class.ts | 10 +++++++++- backend/src/routes/group.ts | 14 ++++++++++++-- backend/src/routes/login.ts | 7 ++++++- backend/src/routes/question.ts | 10 +++++++++- backend/src/routes/student.ts | 24 ++++++++++++++++-------- backend/src/routes/submission.ts | 9 ++++++++- 9 files changed, 74 insertions(+), 20 deletions(-) diff --git a/backend/package.json b/backend/package.json index 85a4d255..8aae346d 100644 --- a/backend/package.json +++ b/backend/package.json @@ -14,9 +14,10 @@ "test:unit": "vitest --run" }, "dependencies": { - "@mikro-orm/core": "^6.4.6", - "@mikro-orm/postgresql": "^6.4.6", - "@mikro-orm/reflection": "^6.4.6", + "@mikro-orm/core": "6.4.6", + "@mikro-orm/postgresql": "6.4.6", + "@mikro-orm/sqlite": "6.4.6", + "@mikro-orm/reflection": "6.4.6", "dotenv": "^16.4.7", "express": "^5.0.1" }, diff --git a/backend/src/app.ts b/backend/src/app.ts index 532f7734..b21ca26b 100644 --- a/backend/src/app.ts +++ b/backend/src/app.ts @@ -1,5 +1,5 @@ import express, { Express, Response } from 'express'; -import initORM from './orm.js'; +import { initORM } from './orm.js'; import studentRouter from './routes/student'; import groupRouter from './routes/group'; @@ -30,7 +30,7 @@ app.use('/login', loginRouter); async function startServer() { - await initORM(); + //await initORM(); app.listen(port, () => { console.log(`Server is running at http://localhost:${port}`); diff --git a/backend/src/routes/assignment.ts b/backend/src/routes/assignment.ts index 0a3b4c02..95116243 100644 --- a/backend/src/routes/assignment.ts +++ b/backend/src/routes/assignment.ts @@ -3,7 +3,14 @@ const router = express.Router(); // information about an assignment with id 'id' router.get('/:id', (req, res) => { - res.send('assignment'); + res.json({ + id: req.params.id, + title: 'Dit is een test assignment', + description: 'Een korte beschrijving', + groups: [ '0' ], + learningPath: '0', + class: '0' + }); }) export default router \ No newline at end of file diff --git a/backend/src/routes/class.ts b/backend/src/routes/class.ts index 746e8662..c9fe4259 100644 --- a/backend/src/routes/class.ts +++ b/backend/src/routes/class.ts @@ -3,7 +3,15 @@ const router = express.Router(); // information about an class with id 'id' router.get('/:id', (req, res) => { - res.send('class'); + res.json({ + id: req.params.id, + displayName: 'Klas 4B', + teachers: [ '0' ], + students: [ '0' ], + assignments: [ '0' ], + joinRequests: [ '0' ], + invitations: [ '0' ], + }); }) export default router \ No newline at end of file diff --git a/backend/src/routes/group.ts b/backend/src/routes/group.ts index 36e0be6e..bca20889 100644 --- a/backend/src/routes/group.ts +++ b/backend/src/routes/group.ts @@ -3,12 +3,22 @@ const router = express.Router(); // information about a group (members, ... [TODO DOC]) router.get('/:id', (req, res) => { - res.send('group'); + res.json({ + id: req.params.id, + assignment: '0', + students: [ '0' ], + submissions: [ '0' ], + // reference to other endpoint + // should be less hardcoded + questions: `/group/${req.params.id}/question`, + }); }) // the list of questions a group has made router.get('/:id/question', (req, res) => { - res.send('questions'); + res.json({ + questions: [ '0' ], + }); }) export default router \ No newline at end of file diff --git a/backend/src/routes/login.ts b/backend/src/routes/login.ts index 691a860c..550e6d93 100644 --- a/backend/src/routes/login.ts +++ b/backend/src/routes/login.ts @@ -3,7 +3,12 @@ const router = express.Router(); // returns login paths for IDP router.get('/', (req, res) => { - res.send('login route'); + res.json({ + // dummy variables, needs to be changed + // with IDP endpoints + leerkracht: '/login-leerkracht', + leerling: '/login-leerling', + }); }) export default router \ No newline at end of file diff --git a/backend/src/routes/question.ts b/backend/src/routes/question.ts index 1de0ae42..2218abf9 100644 --- a/backend/src/routes/question.ts +++ b/backend/src/routes/question.ts @@ -3,7 +3,15 @@ const router = express.Router(); // information about an question with id 'id' router.get('/:id', (req, res) => { - res.send('question'); + res.json({ + id: req.params.id, + student: '0', + group: '0', + time: new Date(2025, 1, 1), + content: 'Zijn alle gehele getallen groter dan 2 gelijk aan de som van 2 priemgetallen????', + answers: [ '0' ], + learningObject: [ '0' ], + }); }) export default router \ No newline at end of file diff --git a/backend/src/routes/student.ts b/backend/src/routes/student.ts index 55582992..3c8cd16c 100644 --- a/backend/src/routes/student.ts +++ b/backend/src/routes/student.ts @@ -2,24 +2,32 @@ import express from 'express' const router = express.Router(); // the list of classes a student is in -router.get('/:id/class', (req, res) => { - res.send('classes'); +router.get('/:id/classes', (req, res) => { + res.json({ + classes: [ '0' ], + }); }) // the list of submissions a student has made -router.get('/:id/submission', (req, res) => { - res.send('submissions'); +router.get('/:id/submissions', (req, res) => { + res.json({ + submissions: [ '0' ], + }); }) // the list of assignments a student has -router.get('/:id/assignment', (req, res) => { - res.send('assignments'); +router.get('/:id/assignments', (req, res) => { + res.json({ + assignments: [ '0' ], + }); }) // the list of groups a student is in -router.get('/:id/group', (req, res) => { - res.send('groups'); +router.get('/:id/groups', (req, res) => { + res.json({ + groups: [ '0' ], + }); }) export default router \ No newline at end of file diff --git a/backend/src/routes/submission.ts b/backend/src/routes/submission.ts index dbec9c8b..b830af8b 100644 --- a/backend/src/routes/submission.ts +++ b/backend/src/routes/submission.ts @@ -3,7 +3,14 @@ const router = express.Router(); // information about an submission with id 'id' router.get('/:id', (req, res) => { - res.send('submission'); + res.json({ + id: req.params.id, + student: '0', + group: '0', + time: new Date(2025, 1, 1), + content: 'Wortel 2 is rationeel', + learningObject: '0', + }); }) export default router \ No newline at end of file From d9998a99eae2f2721a91950e18784a2d8894845d Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Tue, 25 Feb 2025 12:32:06 +0100 Subject: [PATCH 04/13] databank aanpassingen teruggerold, import statement geupdate in app.ts --- backend/src/app.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/app.ts b/backend/src/app.ts index b21ca26b..5e4e781a 100644 --- a/backend/src/app.ts +++ b/backend/src/app.ts @@ -1,5 +1,5 @@ import express, { Express, Response } from 'express'; -import { initORM } from './orm.js'; +import initORM from './orm.js'; import studentRouter from './routes/student'; import groupRouter from './routes/group'; From 8179132811a84c46a31188e52c891374d2c14f7c Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Wed, 26 Feb 2025 13:20:57 +0100 Subject: [PATCH 05/13] fix: MikroORM terug aangezet in backend/src/app.ts --- backend/src/app.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/app.ts b/backend/src/app.ts index 5e4e781a..532f7734 100644 --- a/backend/src/app.ts +++ b/backend/src/app.ts @@ -30,7 +30,7 @@ app.use('/login', loginRouter); async function startServer() { - //await initORM(); + await initORM(); app.listen(port, () => { console.log(`Server is running at http://localhost:${port}`); From e0c756fb361ab0fd3e18a50ee0c8bbe4fb07c52e Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Wed, 26 Feb 2025 14:17:21 +0100 Subject: [PATCH 06/13] feat: /teacher endpoint met dummy JSON voor #48 --- backend/src/routes/teacher.ts | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 backend/src/routes/teacher.ts diff --git a/backend/src/routes/teacher.ts b/backend/src/routes/teacher.ts new file mode 100644 index 00000000..a004ce8c --- /dev/null +++ b/backend/src/routes/teacher.ts @@ -0,0 +1,44 @@ +import express from 'express' +const router = express.Router(); + +// information about an question with id 'id' +router.get('/:id/', (req, res) => { + res.json({ + id: req.params.id, + 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`, + }, + }); +}) + +router.get('/:id/questions', (req, res) => { + res.json({ + questions: [ + '0' + ], + }); +}); + +router.get('/:id/invitations', (req, res) => { + res.json({ + invitations: [ + '0' + ], + }); +}); + +router.get('/:id/classes', (req, res) => { + res.json({ + classes: [ + '0' + ], + }); +}); + + +export default router \ No newline at end of file From bb41fd848c2ea903f374e457b9c9ee96d67ca4fb Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Wed, 26 Feb 2025 14:18:48 +0100 Subject: [PATCH 07/13] feat: commentaar toegevoegd voor de verschillende endpoints in /teacher --- backend/src/routes/teacher.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/src/routes/teacher.ts b/backend/src/routes/teacher.ts index a004ce8c..851da986 100644 --- a/backend/src/routes/teacher.ts +++ b/backend/src/routes/teacher.ts @@ -1,7 +1,7 @@ import express from 'express' const router = express.Router(); -// information about an question with id 'id' +// information about a teacher router.get('/:id/', (req, res) => { res.json({ id: req.params.id, @@ -16,6 +16,7 @@ router.get('/:id/', (req, res) => { }); }) +// the questions students asked a teacher router.get('/:id/questions', (req, res) => { res.json({ questions: [ @@ -24,6 +25,7 @@ router.get('/:id/questions', (req, res) => { }); }); +// invitations to other classes a teacher received router.get('/:id/invitations', (req, res) => { res.json({ invitations: [ @@ -32,6 +34,7 @@ router.get('/:id/invitations', (req, res) => { }); }); +// a list with ids of classes a teacher is in router.get('/:id/classes', (req, res) => { res.json({ classes: [ From 62d4e3bc224d4fe52fa3af8cc5f9d25dab055cab Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Wed, 26 Feb 2025 14:20:58 +0100 Subject: [PATCH 08/13] feat: profiel endpoint van een student toegevoegd --- backend/src/routes/student.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/backend/src/routes/student.ts b/backend/src/routes/student.ts index 3c8cd16c..b799e6aa 100644 --- a/backend/src/routes/student.ts +++ b/backend/src/routes/student.ts @@ -1,6 +1,22 @@ import express from 'express' const router = express.Router(); +// information about a student's profile +router.get('/:id', (req, res) => { + res.json({ + id: req.params.id, + firstName: 'Jimmy', + lastName: 'Faster', + username: 'JimmyFaster2', + endpoints: { + classes: `/student/${req.params.id}/classes`, + questions: `/student/${req.params.id}/submissions`, + invitations: `/student/${req.params.id}/assignments`, + groups: `/student/${req.params.id}/groups`, + }, + }); +}); + // the list of classes a student is in router.get('/:id/classes', (req, res) => { res.json({ From 08e54dbcb1847d1d0b93bf60c7e91023e069572d Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Wed, 26 Feb 2025 14:35:42 +0100 Subject: [PATCH 09/13] 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`, }, }); }) From a7d4868e63e012bf750395b5404769a55ca5a9a5 Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Wed, 26 Feb 2025 14:40:32 +0100 Subject: [PATCH 10/13] feat: extra endpoints toegevoegd voor /assignment --- backend/src/routes/assignment.ts | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/backend/src/routes/assignment.ts b/backend/src/routes/assignment.ts index 95116243..38fffe29 100644 --- a/backend/src/routes/assignment.ts +++ b/backend/src/routes/assignment.ts @@ -9,8 +9,36 @@ router.get('/:id', (req, res) => { description: 'Een korte beschrijving', groups: [ '0' ], learningPath: '0', - class: '0' + class: '0', + links: { + self: `${req.baseUrl}/${req.params.id}`, + submissions: `${req.baseUrl}/${req.params.id}`, + }, }); }) +router.get('/:id/submissions', (req, res) => { + res.json({ + submissions: [ + '0' + ], + }); +}); + +router.get('/:id/groups', (req, res) => { + res.json({ + groups: [ + '0' + ], + }); +}); + +router.get('/:id/questions', (req, res) => { + res.json({ + questions: [ + '0' + ], + }); +}); + export default router \ No newline at end of file From 2e87710fe662af39aedb1e69ffecfeefb76e7bcf Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Wed, 26 Feb 2025 14:42:38 +0100 Subject: [PATCH 11/13] feat: extra endpoints voor /question toegevoegd --- backend/src/routes/question.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/backend/src/routes/question.ts b/backend/src/routes/question.ts index 2218abf9..16b1a484 100644 --- a/backend/src/routes/question.ts +++ b/backend/src/routes/question.ts @@ -9,9 +9,20 @@ router.get('/:id', (req, res) => { group: '0', time: new Date(2025, 1, 1), content: 'Zijn alle gehele getallen groter dan 2 gelijk aan de som van 2 priemgetallen????', - answers: [ '0' ], - learningObject: [ '0' ], + learningObject: '0', + links: { + self: `${req.baseUrl}/${req.params.id}`, + answers: `${req.baseUrl}/${req.params.id}/answers`, + } }); }) +router.get('/:id/answers', (req, res) => { + res.json({ + answers: [ + '0' + ], + }) +}) + export default router \ No newline at end of file From b85374afa8f59f8749ae966d472b69fb918f22cd Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Thu, 27 Feb 2025 16:30:55 +0100 Subject: [PATCH 12/13] feat: root paden toegevoegd aan endpoints --- backend/src/routes/assignment.ts | 10 ++++++++++ backend/src/routes/class.ts | 10 ++++++++++ backend/src/routes/group.ts | 10 ++++++++++ backend/src/routes/question.ts | 10 ++++++++++ backend/src/routes/student.ts | 10 ++++++++++ backend/src/routes/submission.ts | 10 ++++++++++ backend/src/routes/teacher.ts | 12 +++++++++++- 7 files changed, 71 insertions(+), 1 deletion(-) diff --git a/backend/src/routes/assignment.ts b/backend/src/routes/assignment.ts index 38fffe29..fcb6e9da 100644 --- a/backend/src/routes/assignment.ts +++ b/backend/src/routes/assignment.ts @@ -1,6 +1,16 @@ import express from 'express' const router = express.Router(); +// root endpoint used to search objects +router.get('/', (req, res) => { + res.json({ + assignments: [ + '0', + '1', + ] + }); +}); + // information about an assignment with id 'id' router.get('/:id', (req, res) => { res.json({ diff --git a/backend/src/routes/class.ts b/backend/src/routes/class.ts index 4d031587..e554a7f2 100644 --- a/backend/src/routes/class.ts +++ b/backend/src/routes/class.ts @@ -1,6 +1,16 @@ import express from 'express' const router = express.Router(); +// root endpoint used to search objects +router.get('/', (req, res) => { + res.json({ + classes: [ + '0', + '1', + ] + }); +}); + // information about an class with id 'id' router.get('/:id', (req, res) => { res.json({ diff --git a/backend/src/routes/group.ts b/backend/src/routes/group.ts index bca20889..e55dddd1 100644 --- a/backend/src/routes/group.ts +++ b/backend/src/routes/group.ts @@ -1,6 +1,16 @@ import express from 'express' const router = express.Router(); +// root endpoint used to search objects +router.get('/', (req, res) => { + res.json({ + groups: [ + '0', + '1', + ] + }); +}); + // information about a group (members, ... [TODO DOC]) router.get('/:id', (req, res) => { res.json({ diff --git a/backend/src/routes/question.ts b/backend/src/routes/question.ts index 16b1a484..25d168b7 100644 --- a/backend/src/routes/question.ts +++ b/backend/src/routes/question.ts @@ -1,6 +1,16 @@ import express from 'express' const router = express.Router(); +// root endpoint used to search objects +router.get('/', (req, res) => { + res.json({ + questions: [ + '0', + '1', + ] + }); +}); + // information about an question with id 'id' router.get('/:id', (req, res) => { res.json({ diff --git a/backend/src/routes/student.ts b/backend/src/routes/student.ts index b799e6aa..a11c1fbc 100644 --- a/backend/src/routes/student.ts +++ b/backend/src/routes/student.ts @@ -1,6 +1,16 @@ import express from 'express' const router = express.Router(); +// root endpoint used to search objects +router.get('/', (req, res) => { + res.json({ + students: [ + '0', + '1', + ] + }); +}); + // information about a student's profile router.get('/:id', (req, res) => { res.json({ diff --git a/backend/src/routes/submission.ts b/backend/src/routes/submission.ts index b830af8b..8d09cf8e 100644 --- a/backend/src/routes/submission.ts +++ b/backend/src/routes/submission.ts @@ -1,6 +1,16 @@ import express from 'express' const router = express.Router(); +// root endpoint used to search objects +router.get('/', (req, res) => { + res.json({ + submissions: [ + '0', + '1', + ] + }); +}); + // information about an submission with id 'id' router.get('/:id', (req, res) => { res.json({ diff --git a/backend/src/routes/teacher.ts b/backend/src/routes/teacher.ts index 06ab320b..37b3b04b 100644 --- a/backend/src/routes/teacher.ts +++ b/backend/src/routes/teacher.ts @@ -1,8 +1,18 @@ import express from 'express' const router = express.Router(); +// root endpoint used to search objects +router.get('/', (req, res) => { + res.json({ + teachers: [ + '0', + '1', + ] + }); +}); + // information about a teacher -router.get('/:id/', (req, res) => { +router.get('/:id', (req, res) => { res.json({ id: req.params.id, firstName: 'John', From 09923202f3acedd01ea19ced6daf81843e6bd79f Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Thu, 27 Feb 2025 16:31:41 +0100 Subject: [PATCH 13/13] fix: routes/themes.ts bestand verwijderd om conflicten te vermijden --- backend/src/routes/themes.ts | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 backend/src/routes/themes.ts diff --git a/backend/src/routes/themes.ts b/backend/src/routes/themes.ts deleted file mode 100644 index 99f4dd0c..00000000 --- a/backend/src/routes/themes.ts +++ /dev/null @@ -1,10 +0,0 @@ -import express from 'express' -const router = express.Router(); - -// I'm not sure what's supposed to be here -// https://github.com/SELab-2/Dwengo-1/issues/24 -router.get('/', (req, res) => { - res.send('themes route'); -}) - -export default router \ No newline at end of file