Files
supervisor-ui/app/api/supervisor/processes/[name]/stdin/route.ts

30 lines
837 B
TypeScript
Raw Normal View History

import { NextRequest, NextResponse } from 'next/server';
import { createSupervisorClient } from '@/lib/supervisor/client';
import { withLogging } from '@/lib/utils/api-logger';
interface RouteParams {
params: Promise<{ name: string }>;
}
export const POST = withLogging(async (request: NextRequest, { params }: RouteParams) => {
const { name } = await params;
const body = await request.json();
const { chars } = body;
if (chars === undefined || chars === null) {
return NextResponse.json(
{ error: 'Input characters are required' },
{ status: 400 }
);
}
const client = createSupervisorClient();
const result = await client.sendProcessStdin(name, chars);
return NextResponse.json({
success: result,
message: `Input sent to ${name}`,
processName: name,
});
}, 'sendProcessStdin');