Type-safe pub/sub library for Node.js with Zod schema validation.
Plopslop provides ephemeral pub/sub messaging with:
- Type-safe message handling using Zod schemas
- Pluggable drivers (Redis, PostgreSQL, in-memory)
- Plugin system for middleware-style processing
- Async iterator and callback-based APIs
Designed for distributing real-time messages to WebSockets, SSE, and server instances.
pnpm add @plopslop/core @plopslop/redis ioredis zodimport { createPubSub } from '@plopslop/core';
import { redis } from '@plopslop/redis';
import { z } from 'zod';
const pubsub = createPubSub({
driver: redis(),
topics: {
userCreated: {
name: 'user.created',
schema: z.object({ name: z.string() }),
},
},
});
// Subscribe
for await (const { payload } of pubsub.userCreated.stream()) {
console.log(`User ${payload.name} created`);
}
// Publish
await pubsub.userCreated.publish({ name: 'Alice' });See @plopslop/core for full API documentation.
- @plopslop/core - Core library with driver abstraction and plugin system
- @plopslop/redis - Redis driver for distributed pub/sub
- @plopslop/postgres - PostgreSQL driver using LISTEN/NOTIFY
- @plopslop/otel - OpenTelemetry plugin for distributed tracing
- chat-express - Express + WebSocket chat using Redis
- chat-hono - Hono + WebSocket chat using Redis
- chat-next-trpc - Next.js + tRPC with SSE subscriptions
Use plopslop when you need:
- Real-time message distribution across server instances
- Type-safe pub/sub with schema validation
- Low-latency ephemeral messaging
- Integration with WebSockets or Server-Sent Events
Don't use plopslop when you need:
- Guaranteed message delivery
- Message persistence and replay
- Complex routing or message queuing
- Dead letter queues or retries
Plopslop is designed for ephemeral pub/sub, not message queuing or event streaming. Messages are delivered to active subscribers and then discarded. Unlike RabbitMQ or BullMQ, there is no message persistence or acknowledgment. Unlike Kafka or Pulsar, there is no message replay, consumer groups, or offset management.
Use plopslop for broadcasting real-time events. Use message queues (BullMQ, RabbitMQ) for reliable work distribution. Use event streaming platforms (Kafka, Pulsar) for event sourcing and analytics.
See CONTRIBUTING.md for development setup and guidelines.
MIT - see LICENSE