refactor: 🚀 update routes

#10
This commit is contained in:
2024-04-23 11:58:28 +02:00
parent df9efc759c
commit c334b3954f
4 changed files with 47 additions and 37 deletions

View File

@@ -1,29 +1,32 @@
import express, {type Router} from "express";
import JwtGuard from "@validators/JwtGuard";
import AdminGuard from "@validators/AdminGuard";
import UserGuard from "@validators/UserGuard";
const router: Router = express.Router();
// Get rent affected to the user
router.route('/affected').get(JwtGuard)
router.route('/affected')
.get(UserGuard)
// Get all vehicle in rent (admin only)
router.route('/affected/all').get(JwtGuard)
router.route('/affected/all')
.get(AdminGuard)
// Add a new vehicle (admin only)
router.route('/veh/new').post(JwtGuard)
router.route('/veh/new')
.post(AdminGuard)
// Get all vehicles
router.route('/veh/all').get()
router.route('/veh/all')
.get()
// Rent a specific vehicle
router.route('/veh/rent/:vehicleId').post(JwtGuard)
router.route('/veh/rent/:vehicleId')
.post(UserGuard)
// Endpoint to get the data of a vehicle, data change if source is an admin
router.route('/veh/:vehicleId').get(JwtGuard)
// Endpoint to edit the data of a vehicle if source is an admin
router.route('/veh/:vehicleId').patch(JwtGuard)
// Endpoint to delete a vehicle if source is an admin
router.route('/veh/:vehicleId').delete(JwtGuard)
router.route('/veh/:vehicleId')
.get(UserGuard)
.patch(AdminGuard)
.delete(AdminGuard)