MCPcopy Create free account
hub / github.com/sqlchat/sqlchat / handler

Function handler

src/pages/api/connection/test.ts:10–29  ·  view source on GitHub ↗
(req: NextApiRequest, res: NextApiResponse)

Source from the content-addressed store, hash-verified

8// req body: { connection: Connection }
9// It's mainly used to test the connection.
10const handler = async (req: NextApiRequest, res: NextApiResponse) => {
11 if (req.method !== "POST") {
12 return res.status(405).json(false);
13 }
14
15 let connection = req.body.connection as Connection;
16 if (connection.engineType === Engine.TiDB) {
17 connection = changeTiDBConnectionToMySQL(connection);
18 }
19 try {
20 const connector = newConnector(connection);
21 await connector.testConnection();
22 res.status(200).json({});
23 } catch (error: any) {
24 res.status(400).json({
25 message: error.message || "Failed to test connection.",
26 code: error.code || "UNKNOWN",
27 });
28 }
29};
30
31export default handler;

Callers

nothing calls this directly

Calls 2

newConnectorFunction · 0.90

Tested by

no test coverage detected