added API support for posting training reports

This commit is contained in:
2025-11-16 10:10:09 -05:00
parent 0ff3fc58de
commit 810a15d279
3 changed files with 47 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
import { CourseAttendee } from "@app/shared/types/course";
import { getAllCourses, getCourseEventAttendees, getCourseEventDetails } from "../services/CourseSerivce";
import { CourseAttendee, CourseEventDetails } from "@app/shared/types/course";
import { getAllCourses, getCourseEventAttendees, getCourseEventDetails, insertCourseEvent } from "../services/CourseSerivce";
import { Request, Response, Router } from "express";
const courseRouter = Router();
@@ -36,6 +36,18 @@ eventRouter.get('/attendees/:id', async (req: Request, res: Response) => {
}
})
eventRouter.post('/', async (req: Request, res: Response) => {
try {
console.log();
const data: CourseEventDetails = req.body;
await insertCourseEvent(data);
res.sendStatus(201);
} catch (error) {
console.error('failed to post training', error);
res.status(500).json("failed to post training\n" + error)
}
})
// //insert a new latest rank for a user
// ur.post('/', async (req, res) => {