From a624b4c8a223e8226eb4cf0d1b5887f658aeaae5 Mon Sep 17 00:00:00 2001 From: Aarish <118203269+ImprobableGenius@users.noreply.github.com> Date: Thu, 22 May 2025 22:50:19 -0500 Subject: [PATCH] build api endpoints /api --- routes/api.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 routes/api.js diff --git a/routes/api.js b/routes/api.js new file mode 100644 index 0000000..b5dcd12 --- /dev/null +++ b/routes/api.js @@ -0,0 +1,26 @@ +// import router from express +var express = require('express'); +const PlaywrightService = require('../services/PlaywrightService'); +var router = express.Router(); + +/** + * GET run accessibility test on domain + * Only works for homepage + * // TODO: Crawl site map and queue all pages + */ +router.get('/test/accessibility/:domain', function(req, res) { + const domain = req.params.domain; // Get the domain from the request parameters + + const playwrightService = new PlaywrightService(domain); + + // Call the runAccessibilityTest method + playwrightService.runAccessibilityTest().then(results => { + // Send the results as a JSON response + res.json(results); + }).catch(err => { + // Handle any errors that occur during the test + res.status(500).json({ error: err.message }); + }); +}); + +module.exports = router; \ No newline at end of file