Files
speedboard/routes/test.js
Malin 280e5f133f feat: initial Speedboard implementation
sitespeed.io web UI with Express/Pug/SQLite — port 3132.
Includes job queue, SSE live log, full metrics dashboard,
site history, CO2/axe/CWV sections, and Docker support.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-06 19:36:13 +02:00

31 lines
851 B
JavaScript

import { Router } from 'express';
import { v4 as uuidv4 } from 'uuid';
import { createJob } from '../db.js';
import { enqueue } from '../queue.js';
const router = Router();
router.post('/', (req, res) => {
let { url, browser, mobile, runs } = req.body;
// Validate
if (!url || !url.startsWith('http')) {
return res.status(400).render('error', {
title: 'Invalid URL',
message: 'Please provide a valid URL starting with http:// or https://',
});
}
browser = ['chrome', 'firefox'].includes(browser) ? browser : 'chrome';
mobile = mobile === '1' || mobile === 'on' || mobile === true;
runs = Math.min(Math.max(parseInt(runs) || 3, 1), 9);
const id = uuidv4();
createJob(id, url, browser, mobile, runs);
enqueue({ id, url, browser, mobile, runs });
res.redirect(`/status/${id}`);
});
export default router;