feat(daemon): implement content routes for screenshot/text/html retrieval (Task 9)

- Add contentRoutes handler factory in routes/content.ts
- GET /pages/:id/screenshot returns PNG as base64
- GET /pages/:id/text returns document.body.innerText
- GET /pages/:id/html returns document.documentElement.outerHTML
- All use safeStringify, 404 on PAGE_NOT_FOUND
- Register contentRoutes in server.ts
- Add 8 integration tests with mock BrowserManager
This commit is contained in:
2026-08-12 20:58:37 +08:00
parent dd79194179
commit 55fc75eb54
3 changed files with 304 additions and 0 deletions
+2
View File
@@ -1,12 +1,14 @@
import http from 'node:http';
import { healthRoute } from './routes/health.js';
import { pageRoutes } from './routes/pages.js';
import { contentRoutes } from './routes/content.js';
import type { BrowserManager } from './browser-manager.js';
export function startServer(port: number, browserManager?: BrowserManager): Promise<http.Server> {
const routes = [healthRoute];
if (browserManager) {
routes.push(pageRoutes(browserManager));
routes.push(contentRoutes(browserManager));
}
return new Promise((resolve) => {