Fastify MySQL plugin using @databases/mysql to prevent SQL injection attacks. Version 0.4.0 provides a wrapper that exposes mysql property on Fastify instance, supporting queries, transactions, and tasks with built-in SQL injection protection via tagged template literals. It offers result types: raw (default), iterator, and stream. The plugin is actively maintained, ships TypeScript types, and requires Fastify v4+ and @databases/mysql as peer dependencies.
npm install fastify-at-mysqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Registers the MySQL plugin, then uses tagged template literals to safely query users.
Use `fastify.mysql.sql` for all queries.
Upgrade Fastify to v4+ or use an older version of the plugin if needed.
Remove `{ type: 'raw' }` option; raw is now default.Ensure transaction callbacks are async or return a promise.
Access MySQL through the Fastify instance: `fastify.mysql`.
Call `app.register(fastifyMysql, options)` before using `fastify.mysql`.
Ensure MySQL is running and accessible; check environment variables for DB_HOST and DB_PORT.
Run `npm install @databases/mysql`.
Always use `fastify.mysql.sql` tagged template: `fastify.mysql.sql`SELECT * FROM contributors``.