Skip to content

Commit

Permalink
_._ _,-'""`-._
Browse files Browse the repository at this point in the history
(,-.`._,'(       |\`-/|
    `-.-' \ )-`( , o o)
          `-    \`_`"'-

Co-authored-by: liv <[email protected]>
  • Loading branch information
JTrenerry and vilnor committed Apr 24, 2024
1 parent fd272cd commit 15b2fb2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions backend/routes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ router.get('/exams/:examId', async (req: Request, res: Response) => {
res.status(200).json(exam.rows);
});

// Course by code
router.get('/courses/:courseCode', async (req: Request, res: Response) => {
// A course's exams by code
router.get('/courses/:courseCode/exams', async (req: Request, res: Response) => {
const courseCode = req.params.courseCode;
const course = await db.query(`
SELECT examID, examYear, examSemester, examType
Expand All @@ -74,6 +74,17 @@ router.get('/courses/:courseCode', async (req: Request, res: Response) => {
res.status(200).json(course.rows);
});

// A Courses information by code
router.get('/courses/:courseCode', async (req: Request, res: Response) => {
const courseCode = req.params.courseCode;
const course = await db.query(`
SELECT courseName, courseDescription
FROM courses
WHERE courses.courseCode = $1
`, [courseCode]);
res.status(200).json(course.rows);
}

// All courses
router.get('/courses', async (req: Request, res: Response) => {
const offet = req.query.offset ?? 0;
Expand Down

0 comments on commit 15b2fb2

Please sign in to comment.