Registry / database / ac-bootstrap-mysql

ac-bootstrap-mysql

JSON →
library2.0.20jsnpmunverified

MySQL initialization and connection helper for AdmiralCloud applications. Version 2.0.20 supports async/await (promise-based) queries via app.mysqlPromise and legacy callback-based queries via app.mysql. It is fully backwards compatible with version 1, supports AWS RDS SSL certificates, and integrates with app.config for database configuration. Released as part of the AdmiralCloud ecosystem, the package is actively maintained with CI/CD and CodeQL scanning. Key differentiator: it simplifies MySQL bootstrap and querying within the AdmiralCloud framework, providing both promise and callback interfaces.

npm install ac-bootstrap-mysql
INSTALL
IMPORT
SIG · AC-BOOTSTRAP-MYSQL
A
ac-bootstrap-mysql
databasejavascriptv2.0.20
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

acbMysql
import acbMysql from 'ac-bootstrap-mysql'
const acbMysql = require('ac-bootstrap-mysql')
Package is ESM-only since v2.0.0.
acbMysql (default)
const acbMysql = await import('ac-bootstrap-mysql')
Also works with dynamic import for CommonJS projects.
app.mysqlPromise
const [rows, fields] = await app.mysqlPromise[serverName].query(query)
app.mysql[serverName].query(query, callback)
Callback pattern is deprecated in v2; use async/await.
app.mysql
app.mysql[serverName].query(query, callback)
Legacy callback interface retained for backwards compatibility.

Demonstrates initialization with async/await and running a simple SELECT query using the promise interface.

import acbMysql from 'ac-bootstrap-mysql'; const app = { config: { database: { dataTimeFormat: 'YYYY-MM-DD HH:mm:ss', servers: [ { server: 'mydb', host: process.env.DB_HOST ?? 'localhost', port: parseInt(process.env.DB_PORT ?? '3306'), user: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? '', ssl: process.env.DB_SSL ?? undefined } ] } } }; await acbMysql(app, { bootstrapping: false }); const [rows, fields] = await app.mysqlPromise['mydb'].query('SELECT 1 AS test'); console.log(rows);
Debug
Known issues
breakingThe callback interface (app.mysql) is deprecated and may be removed in future versions.
fix
Use app.mysqlPromise with async/await instead.
affects: >=2.0.0
gotchaThe 'ssl' option must be set to 'Amazon RDS' when connecting to AWS RDS instances; leaving it empty or undefined will fail on production.
fix
Ensure ssl: 'Amazon RDS' is in the server config for RDS connections.
affects: >=2.0.0
gotchaThe package expects app.config to be defined. If missing, the initialization will throw an error.
fix
Set app.config.database with the required server array before calling acbMysql.
affects: >=2.0.0
breakingVersion 2.0.0 introduced ESM-only exports. CommonJS require() will not work without dynamic import.
fix
Use import acbMysql from 'ac-bootstrap-mysql' or const acbMysql = await import('ac-bootstrap-mysql').
affects: >=2.0.0
gotchaThe 'bootstrapping' option when set to true will cause the callback to return an error rather than logging and exiting. This can lead to unhandled errors if not properly managed.
fix
Always provide an error callback when using bootstrapping: true.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'query')
Using app.mysqlPromise[serverName] before initialization is complete or with wrong server name.
fix
Ensure acbMysql(app) has resolved and that the server name matches exactly.
Error: connect ECONNREFUSED 127.0.0.1:3306
MySQL server is not running or host/port misconfigured.
fix
Verify MySQL is running and check app.config.database.servers[0].host and port.
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'user'@'host'
Invalid username or password in config.
fix
Check user and password fields in app.config.database.servers[0].
Error: Cannot find module 'ac-bootstrap-mysql'
Package not installed or wrong import style.
fix
Run 'npm install ac-bootstrap-mysql' and use ESM import syntax.
Upgrade
Version history
2.0.20latest on npm
Audit
Dependencies
mysql2requiredProvides MySQL connection and query functionality; used internally.
Agent activity
69 hits · last 30 days
node
61
OpenAI (training)
1
Resources
ac-bootstrap-mysql — npm install ac-bootstrap-mysql · libregistry