Training-Report #27

Merged
Ajdj100 merged 47 commits from Training-Report into main 2025-11-22 14:20:51 -06:00
2 changed files with 17 additions and 1 deletions
Showing only changes of commit 4d0dea553e - Show all commits

View File

@@ -1,5 +1,5 @@
import { CourseAttendee, CourseEventDetails } from "@app/shared/types/course";
import { getAllCourses, getCourseEventAttendees, getCourseEventDetails, insertCourseEvent } from "../services/CourseSerivce";
import { getAllCourses, getCourseEventAttendees, getCourseEventDetails, getCourseEvents, insertCourseEvent } from "../services/CourseSerivce";
import { Request, Response, Router } from "express";
const courseRouter = Router();
@@ -15,6 +15,16 @@ courseRouter.get('/', async (req, res) => {
}
})
eventRouter.get('/', async (req: Request, res: Response) => {
try {
let events: CourseEventDetails[] = await getCourseEvents();
res.status(200).json(events);
} catch (error) {
console.error('failed to fetch reports', error);
res.status(500).json(error);
}
});
eventRouter.get('/:id', async (req: Request, res: Response) => {
try {
let out = await getCourseEventDetails(Number(req.params.id));

View File

@@ -84,4 +84,10 @@ export async function insertCourseEvent(event: CourseEventDetails): Promise<numb
await con.release();
return eventID;
}
}
export async function getCourseEvents(): Promise<CourseEventDetails[]> {
const sql = "SELECT * FROM course_events;";
let events: CourseEventDetails[] = await pool.query(sql);
return events;
}