A Node.js library that turns MySQL/MariaDB binary logs into real-time events using the EventEmitter pattern. Current stable version: 1.0.8. It monitors row changes, DDL, and query logs via replication protocol. Differentiator: lightweight, zero external dependencies, pure JavaScript implementation for MySQL 5.6+ and MariaDB 10+. Release cadence is low; last update was in 2021.
npm install mysql-event-emitterNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
This example initializes a MySQLEventEmitter to listen for row changes, DDL events, and queries, then starts the emitter and stops after 60 seconds.
Assign a unique numeric serverId (e.g., based on host IP hash) for each emitter instance.
Use emitter.on('row', callback) instead of passing callbacks to constructor.Set MySQL server configuration: log_bin=ON, binlog_format=ROW. For MariaDB, enable binlog with mixed or row format.
Use only mysql_native_password authentication plugin user. Consider wrapping credentials via environment variables.
Avoid relying on 'query' event for production systems. Use 'row' and 'ddl' events instead.
Increase max_allowed_packet on both MySQL server and in emitter options (e.g., max_allowed_packet: 1024 * 1024 * 16).
Increase connect timeout, enable TCP keepalive, or implement reconnection logic. In emitter options: connectTimeout: 10000.
Ensure default import is used: import MySQLEventEmitter from 'mysql-event-emitter'.
No dependency data recorded yet.