feat: teacher get, post en delete route

This commit is contained in:
Gabriellvl 2025-03-07 20:05:16 +01:00
parent b8db32161f
commit 6b87722469
6 changed files with 166 additions and 24 deletions

View file

@ -1,31 +1,13 @@
import express from 'express'
import {createTeacherHandler, deleteTeacherHandler, getTeacherHandler} from "../controllers/teachers.js";
const router = express.Router();
// root endpoint used to search objects
router.get('/', (req, res) => {
res.json({
teachers: [
'0',
'1',
]
});
});
router.get('/', getTeacherHandler);
// information about a teacher
router.get('/:id', (req, res) => {
res.json({
id: req.params.id,
firstName: 'John',
lastName: 'Doe',
username: 'JohnDoe1',
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`,
},
});
})
router.post('/', createTeacherHandler);
router.delete('/:username', deleteTeacherHandler);
// the questions students asked a teacher
router.get('/:id/questions', (req, res) => {
@ -55,4 +37,4 @@ router.get('/:id/classes', (req, res) => {
});
export default router
export default router