Hapi plugin that attaches a MySQL connection pool to every request via request.app.db. Provides both plugin registration and manual pool management (init/stop). Uses the `mysql` npm package under the hood. Current stable version is 7.2.7, with a dependency on @hapi/hapi >=19.0.0. Transactions are not handled by the plugin; users must manage them manually. The plugin uses the connection pool pattern, and the pool can be initialized before registration for use outside of hapi.
npm install hapi-plugin-mysqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Registers the MySQL plugin and uses request.app.db to query. Assumes MySQL is running locally.
Handle transactions manually in your route handlers using connection.beginTransaction(), commit(), rollback().
Use request.app.db to access the MySQL connection.
Consider using mysql2 for modern features.
Call await HapiPluginMysql.stop() on server stop or process exit.
Use object destructuring to access init, getConnection, stop, etc.
npm install @hapi/hapi --save
Ensure request.app.db.query error is properly handled with try/catch or reject.
Check that MySQL is running and host is correct.