From f87aecaf75a8503a5e9a85ee28c4dc40adc2586d Mon Sep 17 00:00:00 2001 From: Mathis Date: Fri, 3 May 2024 11:17:45 +0200 Subject: [PATCH] feat(routes): update endpoints in rentRouter Update `rentRouter.ts` to include `VehicleController` methods in route handlers. - Add `VehicleController.getAll` to "/veh/all" route. - Update "/veh/:vehicleId" route to include `VehicleController.getById`, `VehicleController.update`, and `VehicleController.delete`. Issue: #22 Signed-off-by: Mathis --- src/routes/rent/rentRouter.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/routes/rent/rentRouter.ts b/src/routes/rent/rentRouter.ts index f3bd302..3cad5bb 100644 --- a/src/routes/rent/rentRouter.ts +++ b/src/routes/rent/rentRouter.ts @@ -1,27 +1,28 @@ import AdminGuard from "@validators/AdminGuard"; import UserGuard from "@validators/UserGuard"; import express, { type Router } from "express"; +import VehicleController from "@controllers/vehicle.controller"; const RentRouter: Router = express.Router(); // Get rent affected to the user RentRouter.route("/affected").get(UserGuard); -// Get all vehicle in rent (admin only) +// Get all vehicle in rent (admin only) //TODO Non implemented yet RentRouter.route("/affected/all").get(AdminGuard); // Add a new vehicle (admin only) RentRouter.route("/veh/new").post(AdminGuard); // Get all vehicles -RentRouter.route("/veh/all").get(); +RentRouter.route("/veh/all").get(VehicleController.getAll); // Rent a specific vehicle RentRouter.route("/veh/rent/:vehicleId").post(UserGuard); RentRouter.route("/veh/:vehicleId") - .get(UserGuard) - .patch(AdminGuard) - .delete(AdminGuard); + .get(UserGuard, VehicleController.getById) + .patch(AdminGuard, VehicleController.update) + .delete(AdminGuard, VehicleController.delete); export default RentRouter;