feat: WordPress Monitor API + Site Availability Checker
- Add POST /api/wp-monitor endpoint for WP plugin data - Add GET /api/wp-monitor for listing monitored sites - Add checkSiteAvailability() function for HTTP health checks - Add checkAllSitesAvailability() for batch checking - Add /api/scripts/check-sites.ts for cron execution - Add POST /api/monitor/check-sites for manual trigger DeskCRM Task: #1556 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/**
|
||||
* Monitor API Route
|
||||
* GET /api/monitor
|
||||
* GET /api/monitor - Get all monitoring data
|
||||
* POST /api/monitor/check-sites - Trigger site availability check
|
||||
* @author Descomplicar® | @link descomplicar.pt | @copyright 2026
|
||||
*/
|
||||
import { Router } from 'express'
|
||||
@@ -9,6 +10,7 @@ import * as monitoringService from '../services/monitoring.js'
|
||||
|
||||
const router = Router()
|
||||
|
||||
// Get monitoring data
|
||||
router.get('/', async (req: Request, res: Response) => {
|
||||
try {
|
||||
const data = await monitoringService.getMonitoringData()
|
||||
@@ -19,4 +21,21 @@ router.get('/', async (req: Request, res: Response) => {
|
||||
}
|
||||
})
|
||||
|
||||
// Trigger site availability check
|
||||
router.post('/check-sites', async (req: Request, res: Response) => {
|
||||
try {
|
||||
console.log('[Monitor] Manual site check triggered')
|
||||
const result = await monitoringService.checkAllSitesAvailability()
|
||||
res.json({
|
||||
success: true,
|
||||
message: 'Site check completed',
|
||||
...result,
|
||||
timestamp: new Date().toISOString()
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Site check error:', error)
|
||||
res.status(500).json({ error: 'Internal server error', message: (error as Error).message })
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
||||
|
||||
Reference in New Issue
Block a user