A static event contract should be the source of truth, and the Node.js process should refuse to start when a configured event name is outside that contract. Express middleware still validates every client message at runtime. Those are separate trust boundaries.
Choice Startup failure Client input Best fit
Shared static contract Reject bad deployment config Reject unknown or unauthorized events Small fintech chat system with known event types
Runtime registry Reject invalid registry entries Validate against the loaded registry Tenant-specific event catalogs
Accept names and ignore unknowns Starts despite drift Silently drops or mishandles input Almost never appropriate for financial chat
Recommendation: use a shared as const contract, validate configuration before listen() , then apply token-scoped authorization in middleware. It is boring, cheap to reason about, and keeps a typo from becoming a reconnect-only failure.
For a one-person SaaS, that matters more than building an elaborate event platform.…