2024-07-15 22:11:43 -07:00
|
|
|
const router = require("express").Router();
|
|
|
|
|
const { verifyOwnership } = require("../middleware/verifyOwnership");
|
2024-07-15 22:43:55 -07:00
|
|
|
const Monitor = require("../models/Monitor");
|
2024-07-16 11:12:48 -07:00
|
|
|
const {
|
|
|
|
|
getPageSpeedChecks,
|
|
|
|
|
createPageSpeedCheck,
|
|
|
|
|
deletePageSpeedCheck,
|
|
|
|
|
} = require("../controllers/pageSpeedCheckController");
|
2024-07-15 22:11:43 -07:00
|
|
|
|
2024-07-15 22:14:09 -07:00
|
|
|
/**
|
|
|
|
|
* @route POST /:monitorId
|
|
|
|
|
* @description Create a new PageSpeedCheck for a monitor
|
|
|
|
|
* @access Private
|
|
|
|
|
* @param {string} monitorId - The ID of the monitor
|
|
|
|
|
* @middleware verifyOwnership - Ensures the user owns the monitor
|
|
|
|
|
*/
|
2024-07-16 15:09:40 -07:00
|
|
|
|
2024-07-15 22:11:43 -07:00
|
|
|
router.post(
|
|
|
|
|
"/:monitorId",
|
2024-07-15 22:43:20 -07:00
|
|
|
verifyOwnership(Monitor, "monitorId"),
|
2024-07-16 11:12:48 -07:00
|
|
|
createPageSpeedCheck
|
2024-07-15 22:11:43 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
2024-07-15 22:14:09 -07:00
|
|
|
/**
|
|
|
|
|
* @route GET /:monitorId
|
|
|
|
|
* @description Get all PageSpeedChecks for a monitor
|
|
|
|
|
* @access Private
|
|
|
|
|
* @param {string} monitorId - The ID of the monitor
|
|
|
|
|
* @middleware verifyOwnership - Ensures the user owns the monitor
|
|
|
|
|
*/
|
2024-07-16 15:09:40 -07:00
|
|
|
|
2024-07-15 22:11:43 -07:00
|
|
|
router.get(
|
|
|
|
|
"/:monitorId",
|
2024-07-15 22:43:20 -07:00
|
|
|
verifyOwnership(Monitor, "monitorId"),
|
2024-07-16 11:12:48 -07:00
|
|
|
getPageSpeedChecks
|
2024-07-15 22:11:43 -07:00
|
|
|
);
|
|
|
|
|
|
2024-07-15 22:14:09 -07:00
|
|
|
/**
|
|
|
|
|
* @route POST /delete/:monitorId
|
|
|
|
|
* @description Delete all PageSpeedChecks for a monitor
|
|
|
|
|
* @access Private
|
|
|
|
|
* @param {string} monitorId - The ID of the monitor
|
|
|
|
|
* @middleware verifyOwnership - Ensures the user owns the monitor
|
|
|
|
|
*/
|
2024-07-16 15:09:40 -07:00
|
|
|
|
|
|
|
|
router.delete(
|
|
|
|
|
"/:monitorId",
|
2024-07-15 22:43:20 -07:00
|
|
|
verifyOwnership(Monitor, "monitorId"),
|
2024-07-16 11:12:48 -07:00
|
|
|
deletePageSpeedCheck
|
2024-07-15 22:11:43 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = router;
|