0.4.31 • Published 2 months ago

onerpc v0.4.31

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

oneRPC

GitHub Action Codecov npm License

The router-less serverless RPC framework.

oneRPC is a minimal RPC library to convert a server-side function of a type, (input: T) => Promise<S> into (request: Request) => Promise<Response> and make it callable from the client side in a type-safe way.

Currently, we support Next.js Route Handlers and AWS Lambda.

Features

  • 🔮 Seamless client-server communication

    You can call remote procedures just as seamless as calling local functions.

  • 🛡️ Type safe

    Server-client communication is made safe with request and response types in TypeScript which are used by both client and server.

  • 🔥 Serverless first

    Routing is delegated to other frameworks or infrastructures.

  • 🤝 HTTP friendly

    You can leverage full potential of HTTP functionalities, such as cache control headers.

  • 🐁 Minimal dependencies

    It depends only on Web APIs. Thus, it works on many platforms including Node.js, Deno, and edge runtimes.

  • 🌊 Streaming support

    Stream responses are transferred as JSON Lines and clients can consume them chunk by chunk.

Documentation

Here.

Examples

For all examples, see a examples directory.

Next.js with Route Handlers

app/api/foo/route.ts:

import { query } from "onerpc";
import { z } from "zod";

export const GET = query(z.number(), z.string(), (x) => `Hello, ${x}!`, {
  path: "/api/foo",
});

app/page.tsx:

import { type GET } from "@/app/api/foo/route";
import { query } from "onerpc/client";

export default async (): Promise<JSX.Element> => (
  <div>{await query<typeof GET>("/api/foo", 42))}</div>
);

References

License

MIT

0.4.31

2 months ago

0.4.30

2 months ago

0.4.29

3 months ago

0.4.28

4 months ago

0.4.27

4 months ago

0.4.26

5 months ago

0.4.25

5 months ago

0.4.24

5 months ago

0.4.23

5 months ago

0.4.20

6 months ago

0.4.21

6 months ago

0.4.22

5 months ago

0.4.19

6 months ago

0.4.17

7 months ago

0.4.18

6 months ago

0.4.16

11 months ago

0.4.15

12 months ago

0.4.14

12 months ago

0.4.13

12 months ago

0.4.12

12 months ago

0.4.11

12 months ago

0.4.10

12 months ago

0.4.9

12 months ago

0.4.8

12 months ago

0.4.7

12 months ago

0.4.6

12 months ago

0.4.5

12 months ago

0.4.4

12 months ago

0.4.3

12 months ago

0.4.2

12 months ago

0.4.1

12 months ago

0.4.0

12 months ago

0.3.3

12 months ago

0.3.2

12 months ago

0.3.1

12 months ago

0.3.0

12 months ago

0.2.4

12 months ago

0.2.3

12 months ago

0.2.2

12 months ago

0.2.1

12 months ago

0.2.0

12 months ago

0.1.0

12 months ago