- 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
20 lines
421 B
JavaScript
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;
|