( req: NextApiRequest, res: NextApiResponse )
| 8 | } |
| 9 | |
| 10 | export default async function handler( |
| 11 | req: NextApiRequest, |
| 12 | res: NextApiResponse |
| 13 | ) { |
| 14 | if (req.method !== "POST") { |
| 15 | return res.status(405).json({ message: "Method not allowed" }); |
| 16 | } |
| 17 | |
| 18 | const { inputText } = req.body; |
| 19 | try { |
| 20 | const outputText = await translateToHuman( |
| 21 | inputText, |
| 22 | process.env.OPENAI_API_KEY |
| 23 | ); |
| 24 | res.status(200).json({ outputText }); |
| 25 | } catch (error) { |
| 26 | console.error(error); |
| 27 | res.status(500).json({ message: "Error translating to natural language" }); |
| 28 | } |
| 29 | } |
nothing calls this directly
no test coverage detected