ff-admin-server/src/routes/admin/unit/inspection.ts

52 lines
1.3 KiB
TypeScript
Raw Normal View History

2025-05-29 10:52:05 +02:00
import express, { Request, Response } from "express";
import PermissionHelper from "../../../helpers/permissionHelper";
2025-05-31 15:12:16 +02:00
import {
createInspection,
deleteInspectionById,
getAllInspectionsForRelated,
getInspectionById,
updateInspectionById,
} from "../../../controller/admin/unit/inspectionController";
2025-05-29 10:52:05 +02:00
var router = express.Router({ mergeParams: true });
2025-05-31 15:12:16 +02:00
router.get(["/vehicle/:relatedId", "/equipment/:relatedId"], async (req: Request, res: Response) => {
if (req.path.startsWith("/vehicle")) {
req.params.related = "vehicle";
} else {
req.params.related = "equipment";
}
await getAllInspectionsForRelated(req, res);
});
router.get("/:id", async (req: Request, res: Response) => {
await getInspectionById(req, res);
2025-05-29 10:52:05 +02:00
});
2025-05-31 15:12:16 +02:00
router.post(
"/",
PermissionHelper.passCheckMiddleware("create", "unit", "inspection"),
async (req: Request, res: Response) => {
await createInspection(req, res);
}
);
router.patch(
"/:id",
PermissionHelper.passCheckMiddleware("update", "unit", "inspection"),
async (req: Request, res: Response) => {
await updateInspectionById(req, res);
}
);
router.delete(
"/:id",
PermissionHelper.passCheckMiddleware("delete", "unit", "inspection"),
async (req: Request, res: Response) => {
await deleteInspectionById(req, res);
}
);
2025-05-29 10:52:05 +02:00
export default router;