2025-11-23 18:48:23 +01:00
|
|
|
import { NextRequest, NextResponse } from 'next/server';
|
|
|
|
|
import { createSupervisorClient } from '@/lib/supervisor/client';
|
2025-11-23 20:53:23 +01:00
|
|
|
import { withLogging } from '@/lib/utils/api-logger';
|
2025-11-23 18:48:23 +01:00
|
|
|
|
|
|
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
|
|
2025-11-23 20:53:23 +01:00
|
|
|
export const GET = withLogging(async (request: NextRequest) => {
|
|
|
|
|
const searchParams = request.nextUrl.searchParams;
|
|
|
|
|
const offset = parseInt(searchParams.get('offset') || '-4096', 10);
|
|
|
|
|
const length = parseInt(searchParams.get('length') || '4096', 10);
|
2025-11-23 18:48:23 +01:00
|
|
|
|
2025-11-23 20:53:23 +01:00
|
|
|
const client = createSupervisorClient();
|
|
|
|
|
const logs = await client.readLog(offset, length);
|
2025-11-23 18:48:23 +01:00
|
|
|
|
2025-11-23 20:53:23 +01:00
|
|
|
return NextResponse.json({ logs, offset, length });
|
|
|
|
|
}, 'readMainLog');
|
2025-11-23 18:48:23 +01:00
|
|
|
|
2025-11-23 20:53:23 +01:00
|
|
|
export const DELETE = withLogging(async (request: NextRequest) => {
|
|
|
|
|
const client = createSupervisorClient();
|
|
|
|
|
const result = await client.clearLog();
|
|
|
|
|
|
|
|
|
|
return NextResponse.json({ success: result, message: 'Main log cleared' });
|
|
|
|
|
}, 'clearMainLog');
|