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

Function handler

src/pages/api/connection/db.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 get the database list.
10const handler = async (req: NextApiRequest, res: NextApiResponse) => {
11 if (req.method !== "POST") {
12 return res.status(405).json([]);
13 }
14
15 let connection = req.body.connection as Connection;
16 if (connection.engineType === Engine.TiDB) {
17 connection = changeTiDBConnectionToMySQL(connection);
18 }
19
20 try {
21 const connector = newConnector(connection);
22 const databaseNameList = await connector.getDatabases();
23 res.status(200).json(databaseNameList);
24 } catch (error) {
25 res.status(400).json({
26 error: error,
27 });
28 }
29};
30
31export default handler;

Callers

nothing calls this directly

Calls 2

newConnectorFunction · 0.90

Tested by

no test coverage detected