databank verbinding in app.ts uitgezet, dummy json bodies toegevoegd in verschillende routes
This commit is contained in:
		
							parent
							
								
									deb5d772cb
								
							
						
					
					
						commit
						16b8ab368b
					
				
					 9 changed files with 74 additions and 20 deletions
				
			
		|  | @ -14,9 +14,10 @@ | ||||||
|         "test:unit": "vitest --run" |         "test:unit": "vitest --run" | ||||||
|     }, |     }, | ||||||
|     "dependencies": { |     "dependencies": { | ||||||
|         "@mikro-orm/core": "^6.4.6", |         "@mikro-orm/core": "6.4.6", | ||||||
|         "@mikro-orm/postgresql": "^6.4.6", |         "@mikro-orm/postgresql": "6.4.6", | ||||||
|         "@mikro-orm/reflection": "^6.4.6", |         "@mikro-orm/sqlite": "6.4.6", | ||||||
|  |         "@mikro-orm/reflection": "6.4.6", | ||||||
|         "dotenv": "^16.4.7", |         "dotenv": "^16.4.7", | ||||||
|         "express": "^5.0.1" |         "express": "^5.0.1" | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| import express, { Express, Response } from 'express'; | import express, { Express, Response } from 'express'; | ||||||
| import initORM from './orm.js'; | import { initORM } from './orm.js'; | ||||||
| 
 | 
 | ||||||
| import studentRouter from './routes/student'; | import studentRouter from './routes/student'; | ||||||
| import groupRouter from './routes/group'; | import groupRouter from './routes/group'; | ||||||
|  | @ -30,7 +30,7 @@ app.use('/login', loginRouter); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| async function startServer() { | async function startServer() { | ||||||
|     await initORM(); |     //await initORM();
 | ||||||
| 
 | 
 | ||||||
|     app.listen(port, () => { |     app.listen(port, () => { | ||||||
|         console.log(`Server is running at http://localhost:${port}`); |         console.log(`Server is running at http://localhost:${port}`); | ||||||
|  |  | ||||||
|  | @ -3,7 +3,14 @@ const router = express.Router(); | ||||||
| 
 | 
 | ||||||
| // information about an assignment with id 'id'
 | // information about an assignment with id 'id'
 | ||||||
| router.get('/:id', (req, res) => { | 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 | export default router | ||||||
|  | @ -3,7 +3,15 @@ const router = express.Router(); | ||||||
| 
 | 
 | ||||||
| // information about an class with id 'id'
 | // information about an class with id 'id'
 | ||||||
| router.get('/:id', (req, res) => { | 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 | export default router | ||||||
|  | @ -3,12 +3,22 @@ const router = express.Router(); | ||||||
| 
 | 
 | ||||||
| // information about a group (members, ... [TODO DOC])
 | // information about a group (members, ... [TODO DOC])
 | ||||||
| router.get('/:id', (req, res) => { | 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
 | // the list of questions a group has made
 | ||||||
| router.get('/:id/question', (req, res) => { | router.get('/:id/question', (req, res) => { | ||||||
|     res.send('questions'); |     res.json({ | ||||||
|  |         questions: [ '0' ], | ||||||
|  |     }); | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
| export default router | export default router | ||||||
|  | @ -3,7 +3,12 @@ const router = express.Router(); | ||||||
| 
 | 
 | ||||||
| // returns login paths for IDP
 | // returns login paths for IDP
 | ||||||
| router.get('/', (req, res) => { | 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 | export default router | ||||||
|  | @ -3,7 +3,15 @@ const router = express.Router(); | ||||||
| 
 | 
 | ||||||
| // information about an question with id 'id'
 | // information about an question with id 'id'
 | ||||||
| router.get('/:id', (req, res) => { | 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 | export default router | ||||||
|  | @ -2,24 +2,32 @@ import express from 'express' | ||||||
| const router = express.Router(); | const router = express.Router(); | ||||||
| 
 | 
 | ||||||
| // the list of classes a student is in
 | // the list of classes a student is in
 | ||||||
| router.get('/:id/class', (req, res) => { | router.get('/:id/classes', (req, res) => { | ||||||
|     res.send('classes'); |     res.json({ | ||||||
|  |         classes: [ '0' ], | ||||||
|  |     }); | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
| // the list of submissions a student has made
 | // the list of submissions a student has made
 | ||||||
| router.get('/:id/submission', (req, res) => { | router.get('/:id/submissions', (req, res) => { | ||||||
|     res.send('submissions'); |     res.json({ | ||||||
|  |         submissions: [ '0' ], | ||||||
|  |     }); | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
|    |    | ||||||
| // the list of assignments a student has
 | // the list of assignments a student has
 | ||||||
| router.get('/:id/assignment', (req, res) => { | router.get('/:id/assignments', (req, res) => { | ||||||
|     res.send('assignments'); |     res.json({ | ||||||
|  |         assignments: [ '0' ], | ||||||
|  |     }); | ||||||
| }) | }) | ||||||
|    |    | ||||||
| // the list of groups a student is in
 | // the list of groups a student is in
 | ||||||
| router.get('/:id/group', (req, res) => { | router.get('/:id/groups', (req, res) => { | ||||||
|     res.send('groups'); |     res.json({ | ||||||
|  |         groups: [ '0' ], | ||||||
|  |     }); | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
| export default router | export default router | ||||||
|  | @ -3,7 +3,14 @@ const router = express.Router(); | ||||||
| 
 | 
 | ||||||
| // information about an submission with id 'id'
 | // information about an submission with id 'id'
 | ||||||
| router.get('/:id', (req, res) => { | 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 | export default router | ||||||
		Reference in a new issue
	
	 Adriaan Jacquet
						Adriaan Jacquet