Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/k8w/tsrpc
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.
https://github.com/k8w/tsrpc
ajax axios backend-framework express framework full-stack full-stack-developer full-stack-development grpc nestjs node nodejs protobuf rpc runtime-type-checking serialization-algorithm server-framework typescript typescript-rpc-framework typescript-serialization
Last synced: 1 day ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/k8w/tsrpc
- Owner: k8w
- License: mit
- Created: 2017-09-26T03:22:12.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-11-11T15:02:23.000Z (about 1 month ago)
- Last Synced: 2024-11-26T14:00:49.000Z (16 days ago)
- Topics: ajax, axios, backend-framework, express, framework, full-stack, full-stack-developer, full-stack-development, grpc, nestjs, node, nodejs, protobuf, rpc, runtime-type-checking, serialization-algorithm, server-framework, typescript, typescript-rpc-framework, typescript-serialization
- Language: TypeScript
- Homepage:
- Size: 2.51 MB
- Stars: 1,894
- Watchers: 58
- Forks: 201
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-star-libs - k8w / tsrpc
README
# TSRPC
EN / [中文](https://tsrpc.cn/docs/introduction.html)
A TypeScript RPC framework with runtime type checking and binary serialization.
Official site: https://tsrpc.cn (English version is on the way)
## Features
- Runtime type checking
- Binary serialization
- Pure TypeScript, without any decorater or other language
- HTTP / WebSocket / and more protocols...
- Optional backward-compatibility to JSON
- High performance and reliable, verified by services over 100,000,000 users## Create Full-stack Project
```
npx create-tsrpc-app@latest
```## Usage
### Define Protocol (Shared)
```ts
export interface ReqHello {
name: string;
}export interface ResHello {
reply: string;
}
```### Implement API (Server)
```ts
import { ApiCall } from "tsrpc";export async function ApiHello(call: ApiCall) {
call.succ({
reply: 'Hello, ' + call.req.name
});
}
```### Call API (Client)
```ts
let ret = await client.callApi('Hello', {
name: 'World'
});
```## Examples
https://github.com/k8w/tsrpc-examples
## Serialization Algorithm
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](https://github.com/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.
## API Reference
See [API Reference](./docs/api/tsrpc.md).