TSRPC is an RPC framework specially designed for TypeScript. It has been verified by millions of users and is suitable for scenarios such as HTTP API, WebSocket real-time applications, and NodeJS microservices.

characteristic

  • Authentic TypeScript
  • type safety
    • Full code prompts during development to avoid low-level errors
    • Automatic parameter checking at runtime, always type-safe
  • stronger JSON
    • Support for transferring more data types in JSON
    • E.g ArrayBuffer,Date,ObjectId
  • Support binary transfer
    • TypeScript types can be directly encoded as binary
    • Smaller package body, easier to encrypt, no need for Protobuf
  • Serverless support
    • Supports both serverless cloud functions and containerized deployments
    • Compatible with Alibaba Cloud, Tencent Cloud, AWS standards
  • One-click generation of interface documentation
    • One-click generation of interface documents in multiple formats
    • e.g. Swagger/OpenAPI/Markdown
  • multi-protocol
    • Supports both HTTP/WebSocket
    • Transport protocol-agnostic architecture, easily scalable to any channel
  • Cross-platform
    • Browser / applet / App / NodeJS multi-platform support
    • Compatible with Restful API calls, compatible with Internet Explorer 10
  • high performance
    • Single core single process 5000+ QPS throughput (tested on Macbook Air M1, 2020)
    • Verified by tens of millions of user-level projects, unit tests, stress tests, and DevOps solutions are available

Usage example

Define Protocol (Shared)

export interface ReqHello {
  name: string;
}

export interface ResHello {
  reply: string;
}

Implement API (Server)

import { ApiCall } from "tsrpc";

export async function ApiHello(call: ApiCall<ReqHello, ResHello>) {
  call.succ({
    reply: 'Hello, ' + call.req.name
  });
}

Call API (Client)

let ret = await client.callApi('Hello', {
    name: 'World'
});

#TSRPC #Homepage #Documentation #Downloads #TypeScript #Full #Stack #RPC #Framework #News Fast Delivery

Leave a Comment

Your email address will not be published. Required fields are marked *