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>
This commit is contained in:
30
routes/test.js
Normal file
30
routes/test.js
Normal file
@@ -0,0 +1,30 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user