socketio-wildcard

Catch every Socket.IO event with a single wildcard listener

Library
npm
v2.0.0
198stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
52/100Fair
Development Activity60
Maintenance12
Community56
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
53/100Fair
Architecture45
Code Quality55
Innovation40
Learning Curve70

socketio-wildcard is a tiny middleware for Socket.IO that adds a wildcard * event, letting a server or client handler intercept every incoming packet regardless of its event name. It works by monkey-patching the socket’s internal onevent method so any custom emitter (or the built-in Node EventEmitter) also fires a * event alongside the original one, with the full packet data attached.

It supports both server- and client-side usage and works across namespaces, making it useful for centralized logging, debugging, analytics, or building generic message routers on top of Socket.IO v1.x-v2.x.

What You Get

  • A single middleware function that patches socket.onevent to emit a wildcard * event alongside the original event
  • Support for both Socket.IO servers (via io.use(middleware)) and namespaces (nsp.use(middleware))
  • Client-side support by patching io.Manager so wildcard listening also works in browser/Node Socket.IO clients
  • Compatibility with custom event emitters by passing an alternate CustomEmitter constructor

Common Use Cases

  • Logging every inbound Socket.IO event for debugging or auditing without listing each event name
  • Building a generic message router or proxy that forwards all events to another transport
  • Capturing analytics/metrics on all realtime traffic passing through a namespace
  • Bridging legacy code that expects a single generic message handler onto Socket.IO’s named-event model

Under The Hood

Architecture — The entire library is a single file (index.js) that exports a factory function. Calling it returns a Socket.IO middleware: when installed via io.use() or nsp.use(), it replaces the socket’s internal onevent method with a wrapped version that first re-emits the incoming packet under a * event before dispatching it under its original name, so a single wildcard listener sees every event that flows through the socket. Tech Stack — Plain Node.js with zero runtime dependencies; it relies only on the built-in events.EventEmitter (or an injected custom emitter) and Socket.IO’s own packet/onevent contract, so it stays compatible across Socket.IO v1.x-v2.x without pulling in extra tooling. Code Quality — The implementation is under 25 lines, covered by a 139-line Mocha/power-assert test suite, and enforces the standard style guide plus c8 coverage in its npm test/coverage scripts, though the project has seen no substantive commits in years beyond dependency bumps. API Design — Usage is a one-line io.use(require('socketio-wildcard')()) with an optional custom-emitter argument, requiring no configuration objects or additional setup, which makes the wildcard behavior easy to bolt onto an existing Socket.IO server or client.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search