changed the folder structure. separated the routes and added the authmiddleware for authentication
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
const mysql = require("mysql2");
|
||||
const dotenv = require("dotenv");
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const db = mysql.createConnection({
|
||||
host: process.env.DB_HOST,
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_NAME,
|
||||
});
|
||||
|
||||
db.connect((err) => {
|
||||
if (err) {
|
||||
console.error("Database connection failed:", err.stack);
|
||||
return;
|
||||
}
|
||||
console.log("Connected to the MySQL database.");
|
||||
});
|
||||
|
||||
module.exports = db;
|
||||
Reference in New Issue
Block a user