sanitized errors
This commit is contained in:
@@ -932,7 +932,7 @@ router.post("/cost-preview", authenticateToken, async (req, res) => {
|
||||
});
|
||||
|
||||
// Get earnings status for owner's rentals
|
||||
router.get("/earnings/status", authenticateToken, async (req, res) => {
|
||||
router.get("/earnings/status", authenticateToken, async (req, res, next) => {
|
||||
try {
|
||||
const ownerRentals = await Rental.findAll({
|
||||
where: {
|
||||
@@ -960,12 +960,12 @@ router.get("/earnings/status", authenticateToken, async (req, res) => {
|
||||
stack: error.stack,
|
||||
userId: req.user.id,
|
||||
});
|
||||
res.status(500).json({ error: error.message });
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
// Get refund preview (what would happen if cancelled now)
|
||||
router.get("/:id/refund-preview", authenticateToken, async (req, res) => {
|
||||
router.get("/:id/refund-preview", authenticateToken, async (req, res, next) => {
|
||||
try {
|
||||
const preview = await RefundService.getRefundPreview(
|
||||
req.params.id,
|
||||
@@ -980,12 +980,12 @@ router.get("/:id/refund-preview", authenticateToken, async (req, res) => {
|
||||
rentalId: req.params.id,
|
||||
userId: req.user.id,
|
||||
});
|
||||
res.status(400).json({ error: error.message });
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
// Get late fee preview
|
||||
router.get("/:id/late-fee-preview", authenticateToken, async (req, res) => {
|
||||
router.get("/:id/late-fee-preview", authenticateToken, async (req, res, next) => {
|
||||
try {
|
||||
const { actualReturnDateTime } = req.query;
|
||||
|
||||
@@ -1020,12 +1020,12 @@ router.get("/:id/late-fee-preview", authenticateToken, async (req, res) => {
|
||||
rentalId: req.params.id,
|
||||
userId: req.user.id,
|
||||
});
|
||||
res.status(400).json({ error: error.message });
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
// Cancel rental with refund processing
|
||||
router.post("/:id/cancel", authenticateToken, async (req, res) => {
|
||||
router.post("/:id/cancel", authenticateToken, async (req, res, next) => {
|
||||
try {
|
||||
const { reason } = req.body;
|
||||
|
||||
@@ -1092,12 +1092,12 @@ router.post("/:id/cancel", authenticateToken, async (req, res) => {
|
||||
rentalId: req.params.id,
|
||||
userId: req.user.id,
|
||||
});
|
||||
res.status(400).json({ error: error.message });
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
// Mark item return status (owner only)
|
||||
router.post("/:id/mark-return", authenticateToken, async (req, res) => {
|
||||
router.post("/:id/mark-return", authenticateToken, async (req, res, next) => {
|
||||
try {
|
||||
const { status, actualReturnDateTime, statusOptions } = req.body;
|
||||
const rentalId = req.params.id;
|
||||
@@ -1253,12 +1253,12 @@ router.post("/:id/mark-return", authenticateToken, async (req, res) => {
|
||||
userId: req.user.id,
|
||||
});
|
||||
|
||||
res.status(400).json({ error: error.message });
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
// Report item as damaged (owner only)
|
||||
router.post("/:id/report-damage", authenticateToken, async (req, res) => {
|
||||
router.post("/:id/report-damage", authenticateToken, async (req, res, next) => {
|
||||
try {
|
||||
const rentalId = req.params.id;
|
||||
const userId = req.user.id;
|
||||
@@ -1290,7 +1290,7 @@ router.post("/:id/report-damage", authenticateToken, async (req, res) => {
|
||||
userId: req.user.id,
|
||||
});
|
||||
|
||||
res.status(400).json({ error: error.message });
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user