Remote Procedure Calls in Typescript made simple 🤞

rpc_ts provides a hassle-free way to define APIs in TypeScript so that we can build isomorphic web applications faster.

Get Started

GitHub

TypeScript-native

Clean API contracts written in TypeScript. Ideal for modern isomorphic web applications.

Hassle-free

No Domain Specific Language, no code generation, no proxy. Improve the developer experience without compromising correctness.

Based on proven technologies

Implements the gRPC-Web+json protocol.

Syntax

RPC Service Definition

const helloService = {
    getHello: {
    request: {} as { language: string },
    response: {} as { text: string },
  },
};

RPC Server

const app = express();
app.use(ModuleRpcProtocolServer.registerRpcRoutes(helloService, {
  async getHello({ language }) {
    if (language === 'Spanish') return { text: 'Hola' };
    return { text: 'Hello' };
  },
}));
http.createServer(app).listen(3000);

Type-Safe Remote Procedure Call

const { text } = await ModuleRpcProtocolClient.getRpcClient(helloService, {
  remoteAddress: 'http://localhost:3000'
}).getHello({ language: 'Spanish' });

Examples

rpc_ts_primer

A minimal, functional example for rpc_ts.

GitHub
rpc_ts_chat

Example chat room with rpc_ts (real-time, React+Redux).

GitHub
rpc_ts_aws_cognito

Example authentication for rpc_ts with AWS Cognito.

GitHub

Why rpc_ts?

rpc_ts was made for the startup engineer who prioritizes time to market, readability and correctness.

rpc_ts was developed with agility first and foremost in mind. It does not explicitly address scalability or performance (although this should not be a problem, really), but helps writing Minimal Viable web apps, decreasing time to market, and improving the developer experience without compromising correctness.

rpc_ts was made for the startup engineer who recognizes that using one language is always preferable to using many, that proven technologies should be favoured over new, shiny ones, and that messing with the toolchain to enable code generation with custom DSLs (Domain-Specific Languages) is a time pit.

We believe that rpc_ts fills an important gap in the RPC ecosystem: it provides a hassle-free way to define APIs in an expressive language, TypeScript, so that we can build isomorphic applications faster. 🏖

For more info about this positioning, including a comparison with other technologies, see our open-sourcing announcement.

Articles

Open sourcing rpc_ts, an RPC framework for TypeScript.

rpc_ts is a framework for type-safe Remote Procedure Calls (RPC) in TypeScript. In this post, I'm going to compare our design to other solutions out there and go through the rationale for coming up with rpc_ts.

Read more
How to write an authentication middleware for rpc_ts: the case of AWS Cognito.

This post shows how you can add authentication to an rpc_ts API using AWS Cognito.

Coming soon