feat: add GET /profiles route
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
@@ -3,11 +3,12 @@ import { healthRoute } from './routes/health.js';
|
|||||||
import { pageRoutes } from './routes/pages.js';
|
import { pageRoutes } from './routes/pages.js';
|
||||||
import { contentRoutes } from './routes/content.js';
|
import { contentRoutes } from './routes/content.js';
|
||||||
import { actionRoutes } from './routes/actions.js';
|
import { actionRoutes } from './routes/actions.js';
|
||||||
|
import { profilesRoute } from './routes/profiles.js';
|
||||||
import type { BrowserManager } from './browser-manager.js';
|
import type { BrowserManager } from './browser-manager.js';
|
||||||
import { createWsRelay } from './ws-relay.js';
|
import { createWsRelay } from './ws-relay.js';
|
||||||
|
|
||||||
export function startServer(port: number, browserManager?: BrowserManager): Promise<http.Server> {
|
export function startServer(port: number, browserManager?: BrowserManager): Promise<http.Server> {
|
||||||
const routes = [healthRoute];
|
const routes = [healthRoute, profilesRoute];
|
||||||
if (browserManager) {
|
if (browserManager) {
|
||||||
routes.push(pageRoutes(browserManager));
|
routes.push(pageRoutes(browserManager));
|
||||||
routes.push(contentRoutes(browserManager));
|
routes.push(contentRoutes(browserManager));
|
||||||
|
|||||||
Reference in New Issue
Block a user