2025-11-23 19:46:47 +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 19:46:47 +01:00
|
|
|
|
|
|
|
|
interface RouteParams {
|
|
|
|
|
params: Promise<{ name: string }>;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-23 20:53:23 +01:00
|
|
|
export const POST = withLogging(async (request: NextRequest, { params }: RouteParams) => {
|
|
|
|
|
const { name } = await params;
|
|
|
|
|
const body = await request.json();
|
|
|
|
|
const { chars } = body;
|
2025-11-23 19:46:47 +01:00
|
|
|
|
2025-11-23 20:53:23 +01:00
|
|
|
if (chars === undefined || chars === null) {
|
2025-11-23 19:46:47 +01:00
|
|
|
return NextResponse.json(
|
2025-11-23 20:53:23 +01:00
|
|
|
{ error: 'Input characters are required' },
|
|
|
|
|
{ status: 400 }
|
2025-11-23 19:46:47 +01:00
|
|
|
);
|
|
|
|
|
}
|
2025-11-23 20:53:23 +01:00
|
|
|
|
|
|
|
|
const client = createSupervisorClient();
|
|
|
|
|
const result = await client.sendProcessStdin(name, chars);
|
|
|
|
|
|
|
|
|
|
return NextResponse.json({
|
|
|
|
|
success: result,
|
|
|
|
|
message: `Input sent to ${name}`,
|
|
|
|
|
processName: name,
|
|
|
|
|
});
|
|
|
|
|
}, 'sendProcessStdin');
|