import mysql from "mysql2"; // MySQL connection setup (you can move this to a separate config file if needed) const db = mysql.createConnection({ host: "db-mysql-nyc1-99306-do-user-12431193-0.b.db.ondigitalocean.com", user: "doadmin", password: "AVNS_EPHqPilzmVjZfm8GH4G", database: "defaultdb", port: "25060", }); // Connect to MySQL database db.connect((err) => { if (err) { console.error("Database connection failed: " + err.stack); return; } console.log("Connected to the MYSQL database."); }); // Controller function export const searchMySQL = (req, res) => { const q = "SELECT * FROM client_info"; db.query(q, (err, data) => { if (err) { console.log(err); return res.status(500).json({ error: "Database query failed" }); } return res.json(data); }); };