Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit 266307da authored by 65160014's avatar 65160014
Browse files

Initial commit

parent b6502efd
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@ const app = express();
const port = 3000;
// การตั้งค่าการเชื่อมต่อฐานข้อมูล MySQL (ใช้ pool)
const db = mysql.createConnection({
const db = mysql.createPool({
host: process.env.DB_HOST,
port: process.env.DB_PORT,
user: process.env.DB_USER,
......@@ -17,14 +17,14 @@ const db = mysql.createConnection({
});
// Test the database connection to ensure everything is set up correctly
db.connect(err => {
db.getConnection((err, connection) => {
if (err) throw err;
console.log("Connected to the database.");
connection.release(); // Release the connection back to the pool
});
module.exports = { db };
// การตั้งค่า Express session
app.use(session({
secret: 'your_secret_key',
......@@ -55,8 +55,8 @@ app.get('/', (req, res) => {
app.use('/auth', require('./routes/auth'));
app.use('/admin', require('./routes/admin'));
app.use('/customer', require('./routes/customer'));
// Starting the server
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});
\ No newline at end of file
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment