changed the folder structure. separated the routes and added the authmiddleware for authentication

This commit is contained in:
2024-09-18 22:07:23 +08:00
parent 023505fa0b
commit 0c9e1a4216
7 changed files with 145 additions and 118 deletions
+21
View File
@@ -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;