$ account tsrpc
TSRPC is a TypeScript RPC framework designed for building type-safe, high-performance client-server applications. It provides both HTTP and WebSocket transports with optional JSON compatibility. The framework is built on a custom binary serialization algorithm (TSBuffer) that supports advanced TypeScript type features like union types, intersection types, and mapped types, eliminating the need for external IDL languages. TSRPC includes a rich middleware system called Flows, allowing interception and transformation of data at various stages of request/response processing. The core architecture is abstract and extensible: BaseServer, BaseConnection, and BaseCall form the foundation, with concrete implementations for HTTP (HttpServer, HttpConnection, ApiCallHttp) and WebSocket (WsServer, WsConnection, ApiCallWs). The client side mirrors this with HttpClient and WsClient that handle protocol encoding/decoding, timeouts, and automatic request aborting. The framework also supports server-to-client messages, broadcasting, heartbeat management, and graceful shutdown. With over 1900 GitHub stars and an active maintenance history (latest version 3.4.21), the codebase demonstrates solid engineering practices: comprehensive test coverage across multiple transport modes (HTTP, HTTPS, WS, WSS, both binary and JSON), clean separation of concerns, and robust error handling. The repository includes benchmarking tools and integration tests that verify correctness under various conditions.