Observer embryo, Maestro done

This commit is contained in:
STEINNI
2026-06-13 13:47:46 +00:00
parent 932b6e4752
commit 26aefd3fe2
45 changed files with 1889 additions and 143 deletions
+29
View File
@@ -0,0 +1,29 @@
import mysql from 'mysql2/promise'
export function resolveMysqlCredentials(config = {}) {
const user = process.env.user
const password = process.env.mysql_pass
if(!user || !password) {
throw new Error('Missing MySQL credentials: set user and mysql_pass in environment')
}
return({
socketPath: config.socketPath,
host: config.host,
port: config.port,
user,
password,
database: config.database ?? 'p42GUI',
waitForConnections: true,
connectionLimit: config.connectionLimit ?? 5,
queueLimit: 0,
})
}
export async function createMysqlPool(config) {
return(await mysql.createPool(resolveMysqlCredentials(config)))
}
export async function mysqlExecute(pool, query, values = []) {
const [rows] = await pool.execute(query, values)
return(rows)
}