Socket
Socket
Sign inDemoInstall

tsrpc

Package Overview
Dependencies
Maintainers
1
Versions
215
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsrpc

A TypeScript RPC Framework, with runtime type checking and built-in serialization, support both HTTP and WebSocket.


Version published
Weekly downloads
64
increased by16.36%
Maintainers
1
Weekly downloads
 
Created
Source

TSRPC

EN / 中文

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)

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'
});

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, 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.

Keywords

FAQs

Package last updated on 04 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc