build api endpoints /api
This commit is contained in:
26
routes/api.js
Normal file
26
routes/api.js
Normal file
@@ -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;
|
||||||
Reference in New Issue
Block a user