MCPcopy
hub / github.com/whoiskatrin/sql-translator / handler

Function handler

pages/api/translate.ts:10–27  ·  view source on GitHub ↗
(
  req: NextApiRequest,
  res: NextApiResponse
)

Source from the content-addressed store, hash-verified

8}
9
10export default async function handler(
11 req: NextApiRequest,
12 res: NextApiResponse
13) {
14 const { inputText, tableSchema } = req.body;
15 try {
16 const result = await translateToSQL(
17 inputText,
18 process.env.OPENAI_API_KEY,
19 tableSchema
20 );
21 // console.log(res);
22 res.status(200).json({ outputText: result });
23 } catch (error) {
24 console.error(error);
25 res.status(500).json({ message: "Error translating to SQL" });
26 }
27}

Callers

nothing calls this directly

Calls 1

translateToSQLFunction · 0.85

Tested by

no test coverage detected