admin_dashboard_backend/db/connection.js
SnippetsX 51a73350ae Update configuration and enhance system stats route
- Updated database credentials and application name in config.json
- Refactored database connection to use config values
- Improved CPU usage calculation in systemStats route using node-os-utils
- Added new actions route with user permission checks and config retrieval
- Introduced example_config.json for reference
2024-11-30 01:29:02 +03:00

20 lines
421 B
JavaScript

const mysql = require('mysql2');
const config = require('../config.json');
const db = mysql.createConnection({
host: config.databaseHost,
user: config.databaseUser,
password: config.databasePassword,
database: config.database
});
db.connect((err) => {
if (err) {
console.error('Error connecting to database:', err);
return;
}
console.log('Connected to MySQL database');
});
module.exports = db;