(req: NextRequest)
| 3 | import pipeSummary from '../../../../../baseai/pipes/summary'; |
| 4 | |
| 5 | export async function POST(req: NextRequest) { |
| 6 | const runOptions = await req.json(); |
| 7 | |
| 8 | // 1. Initiate the Pipe. |
| 9 | const pipe = new Pipe(pipeSummary()); |
| 10 | |
| 11 | // 2. Run the pipe |
| 12 | try { |
| 13 | const result = await pipe.run(runOptions); |
| 14 | |
| 15 | // 3. Return the response stringified. |
| 16 | return new Response(JSON.stringify(result)); |
| 17 | } catch (error: any) { |
| 18 | // 4. Return the error response |
| 19 | |
| 20 | return new Response( |
| 21 | JSON.stringify({ |
| 22 | error, |
| 23 | }), |
| 24 | { |
| 25 | status: error.status || 500, |
| 26 | headers: { |
| 27 | 'Content-Type': 'application/json', |
| 28 | }, |
| 29 | }, |
| 30 | ); |
| 31 | } |
| 32 | } |
nothing calls this directly
no test coverage detected