From f45a9aa5a5980c6b59a99726095217edfea847f0 Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Tue, 25 Feb 2025 11:03:00 +0100 Subject: [PATCH] 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