A TypeScript RPC framework, with runtime type checking and serialization, support both HTTP and WebSocket. It is very suitable for website / APP / games, and absolutely comfortable to full-stack TypeScript developers.
EN / 中文
A TypeScript RPC framework with runtime type checking and binary serialization.
Official site: https://tsrpc.cn (English version is on the way)
npx create-tsrpc-app@latest
export interface ReqHello {
name: string;
}
export interface ResHello {
reply: string;
}
import { ApiCall } from "tsrpc";
export async function ApiHello(call: ApiCall<ReqHello, ResHello>) {
call.succ({
reply: 'Hello, ' + call.req.name
});
}
let ret = await client.callApi('Hello', {
name: 'World'
});
https://github.com/k8w/tsrpc-examples
The best TypeScript serialization algorithm ever.
Without any 3rd-party IDL language (like protobuf), it is fully based on TypeScript source file. Define the protocols directly by your code.
This is powered by TSBuffer, which is going to be open-source.
TypeScript has the best type system, with some unique advanced features like union type, intersection type, mapped type, etc.
TSBuffer may be the only serialization algorithm that support them all.
See API Reference.