forked from CSI-KJSCE/appointment_to_examiner
Added backend and integration for FilterPage and CourseTable done
This commit is contained in:
29
server/routes/facultyRoutes.js
Normal file
29
server/routes/facultyRoutes.js
Normal file
@@ -0,0 +1,29 @@
|
||||
const express = require("express");
|
||||
const Faculty = require("../models/Faculty");
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
// Get all faculty members
|
||||
router.get("/", async (req, res) => {
|
||||
try {
|
||||
const faculty = await Faculty.find();
|
||||
res.json(faculty);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: "Failed to fetch faculty members" });
|
||||
}
|
||||
});
|
||||
|
||||
// Get faculty by ID
|
||||
router.get("/:id", async (req, res) => {
|
||||
try {
|
||||
const faculty = await Faculty.findOne({ facultyId: req.params.id });
|
||||
if (!faculty) {
|
||||
return res.status(404).json({ error: "Faculty member not found" });
|
||||
}
|
||||
res.json(faculty);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: "Failed to fetch faculty member" });
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user