socketio-wildcard
Catch every Socket.IO event with a single wildcard listener
Repository Health
Technical Analysis
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.oneventto 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.Managerso wildcard listening also works in browser/Node Socket.IO clients - Compatibility with custom event emitters by passing an alternate
CustomEmitterconstructor
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.
Used by 2 apps in this directory
Artillery
Devops · Developer Tools
Cloud-scale load testing and functional testing for APIs, WebSockets, gRPC, and headless browsers, distributed across AWS Lambda or Fargate with zero infrastructure to manage.
Hoppscotch
Developer Tools
A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.