wisdom #64

Merged
zain_arif merged 4 commits from wisdom into main 2026-07-08 07:18:55 +00:00
Showing only changes of commit 1c56239fc8 - Show all commits

View File

@@ -1,5 +1,8 @@
const express = require('express'); const express = require('express');
const router = express.Router(); const router = express.Router();
const verifyToken = require("../middleware/verifyToken");
const verifyAccess = require("../middleware/verifyAccess");
const NotifikasiWaService = require('../services/notifikasi-wa.service'); const NotifikasiWaService = require('../services/notifikasi-wa.service');
router.post('/restart-wa', async (req, res) => { router.post('/restart-wa', async (req, res) => {
@@ -11,18 +14,18 @@ router.post('/restart-wa', async (req, res) => {
} }
}); });
router.post('/reminder-monthly/:id', async (req, res) => { router.post('/reminder-monthly/:id',verifyToken, verifyAccess, async (req, res) => {
try { try {
const { id } = req.params; const { id } = req.params;
const {reminder_at_monthly, period} = req.body const {reminder_at_monthly} = req.body
const result = await NotifikasiWaService.onMonthlyReminder(id, reminder_at_monthly, period); const result = await NotifikasiWaService.onMonthlyReminder(id, reminder_at_monthly);
return res.status(200).json(result); return res.status(200).json(result);
} catch (error) { } catch (error) {
return res.status(500).json(error); return res.status(500).json(error);
} }
}); });
router.post('/reminder-custom/:id', async (req, res) => { router.post('/reminder-custom/:id',verifyToken, verifyAccess, async (req, res) => {
try { try {
const { id } = req.params; const { id } = req.params;
const {start_date, end_date} = req.body; const {start_date, end_date} = req.body;
@@ -33,52 +36,51 @@ router.post('/reminder-custom/:id', async (req, res) => {
} }
}); });
router.get('/cron/jobs', async (req, res) => { // router.get('/cron/jobs', async (req, res) => {
try { // try {
const activeJobs = NotifikasiWaService.getActiveCronJobs(); // const activeJobs = NotifikasiWaService.getActiveCronJobs();
return res.status(200).json({ // return res.status(200).json({
success: true, // success: true,
total: activeJobs.length, // total: activeJobs.length,
jobs: activeJobs // jobs: activeJobs
}); // });
} catch (error) { // } catch (error) {
return res.status(500).json({ // return res.status(500).json({
success: false, // success: false,
message: error.message // message: error.message
}); // });
} // }
}); // });
router.delete('/cron/jobs/:deviceId', async (req, res) => { // router.delete('/cron/jobs/:deviceId', async (req, res) => {
try { // try {
const { deviceId } = req.params; // const { deviceId } = req.params;
NotifikasiWaService.stopCronJob(deviceId); // NotifikasiWaService.stopCronJob(deviceId);
return res.status(200).json({ // return res.status(200).json({
success: true, // success: true,
message: `Cron job untuk device ${deviceId} dihentikan` // message: `Cron job untuk device ${deviceId} dihentikan`
}); // });
} catch (error) { // } catch (error) {
return res.status(500).json({ // return res.status(500).json({
success: false, // success: false,
message: error.message // message: error.message
}); // });
} // }
}); // });
// Endpoint untuk menghentikan semua cron job // router.delete('/cron/jobs', async (req, res) => {
router.delete('/cron/jobs', async (req, res) => { // try {
try { // NotifikasiWaService.stopAllCronJobs();
NotifikasiWaService.stopAllCronJobs(); // return res.status(200).json({
return res.status(200).json({ // success: true,
success: true, // message: 'Semua cron job dihentikan'
message: 'Semua cron job dihentikan' // });
}); // } catch (error) {
} catch (error) { // return res.status(500).json({
return res.status(500).json({ // success: false,
success: false, // message: error.message
message: error.message // });
}); // }
} // });
});
module.exports = router; module.exports = router;