Software: Apache. PHP/8.1.30 uname -a: Linux server1.tuhinhossain.com 5.15.0-163-generic #173-Ubuntu SMP Tue Oct 14 17:51:00 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 { Renter,RentPayment} from '../models/index.js';
import path from 'path';
import { fileURLToPath } from 'url';
const router = express.Router();
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
router.get('/', async (req, res) => {
try {
const renters = await Renter.findAll({
order: [['created_at', 'DESC']],
});
const nowDate = new Date();
const monthNames = [
'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December'
];
const currentMonth = monthNames[nowDate.getMonth()]; // Month name
const currentYear = nowDate.getFullYear();
for (const renter of renters) {
const existingPayment = await RentPayment.findOne({
where: {
renter_id: renter.id,
month: currentMonth,
year: currentYear,
},
});
if (!existingPayment) {
await RentPayment.create({
renter_id: renter.id,
renterName: renter.name,
room_number: renter.room_id,
user_id: renter.user_id,
amount: renter.rent_amount,
due_date: nowDate,
status: 'pending',
month: currentMonth, // store month name
year: currentYear,
});
}
}
res.json({ message: 'Rent requests created successfully.' });
} catch (err) {
console.error(err);
res.status(500).json({ error: 'Failed to create request-rent' });
}
});
router.get('/download/apk', (req, res) => {
try {
// This is the public URL your frontend can use
const downloadUrl = '/uploads/rentals.apk';
// Send the URL as JSON
res.json({ url: downloadUrl });
} catch (error) {
console.error('Server error:', error);
res.status(500).send('Server error.');
}
});
export default router; |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0036 ]-- |