Releases: kriasoft/bun-ws-router
Releases · kriasoft/bun-ws-router
v0.2.0
🚀 Major Features
Valibot Integration - The biggest addition in this release is full Valibot support as an alternative to Zod for message
validation. You can now choose between:
- Zod (recommended for beginners, familiar API)
- Valibot (90% smaller bundles, better performance)
🔧 Architecture Improvements
Modular Design - Complete restructuring of the codebase with:
- Adapter Pattern: Core logic separated into shared/ directory with thin Zod/Valibot adapters
- Cleaner Exports: Both validation libraries now have dedicated entry points (/zod and /valibot)
- Better Type Safety: Enhanced TypeScript support with full type inference from schema to handler
📦 New Structure
├── shared/ # Core router logic
├── zod/ # Zod adapter and utilities
├── valibot/ # Valibot adapter and utilities
└── test/ # Comprehensive test suite
🎯 Key Improvements
- Backward Compatibility: Existing Zod-based code continues to work unchanged
- Enhanced Testing: Added comprehensive test coverage for both validation libraries
- Better Documentation: Updated README with clear examples for both Zod and Valibot
- Type Safety: Improved TypeScript definitions and error handling
🔄 Breaking Changes
- None - This is a fully backward-compatible release
- Existing Zod-based implementations will continue to work as before
- Default export remains the Zod adapter for compatibility
📝 Usage Examples
// With Zod (existing approach):
import { messageSchema, WebSocketRouter } from "bun-ws-router";
// With Valibot (new option):
import { messageSchema, WebSocketRouter } from "bun-ws-router/valibot";
PRs
- feat: integrate Valibot by @koistya in #2
- feat: publish() function with schema validation by @koistya in #1
Full Changelog: v0.0.3...v0.2.0