import mysql from 'mysql2' const env = process.env.NODE_ENV ?? 'development' const config = require('./config')[env] // ==== USER ACOOUNT DB CONNECTION ==== const userConnection = mysql.createConnection({ host: config.database.host, user: config.database.user, password: config.database.password, port: config.database.port, database: config.database.dbUser, multipleStatements: true }) userConnection.connect(function (err) { if (err != null) throw err }) userConnection.query('USE ' + String(config.database.dbUser)) // ==== PROJECT DB CONNECTION ==== const projectConnection = mysql.createConnection({ host: config.database.host_project, user: config.database.user, password: config.database.password, port: config.database.port, database: config.database.dbProject }) projectConnection.connect(function (err) { if (err != null) throw err }) projectConnection.query('USE ' + String(config.database.dbProject)) const connection = { user: userConnection, project: projectConnection } export = connection