diff --git a/packages/daemon/src/routes/profiles.ts b/packages/daemon/src/routes/profiles.ts new file mode 100644 index 0000000..19f64e3 --- /dev/null +++ b/packages/daemon/src/routes/profiles.ts @@ -0,0 +1,14 @@ +// Profiles API route — list available fingerprint profiles / 指纹配置 API 路由 +import type { IncomingMessage, ServerResponse } from 'node:http'; +import { listProfiles } from '../stealth/index.js'; + +export function profilesRoute(req: IncomingMessage, res: ServerResponse): boolean { + const url = new URL(req.url || '/', 'http://localhost'); + if (req.method === 'GET' && url.pathname === '/profiles') { + const data = listProfiles(); + res.writeHead(200, { 'Content-Type': 'application/json' }); + res.end(JSON.stringify({ ok: true, data })); + return true; + } + return false; +} diff --git a/packages/daemon/src/server.ts b/packages/daemon/src/server.ts index b5061b3..8a97d2a 100644 --- a/packages/daemon/src/server.ts +++ b/packages/daemon/src/server.ts @@ -3,11 +3,12 @@ import { healthRoute } from './routes/health.js'; import { pageRoutes } from './routes/pages.js'; import { contentRoutes } from './routes/content.js'; import { actionRoutes } from './routes/actions.js'; +import { profilesRoute } from './routes/profiles.js'; import type { BrowserManager } from './browser-manager.js'; import { createWsRelay } from './ws-relay.js'; export function startServer(port: number, browserManager?: BrowserManager): Promise { - const routes = [healthRoute]; + const routes = [healthRoute, profilesRoute]; if (browserManager) { routes.push(pageRoutes(browserManager)); routes.push(contentRoutes(browserManager));