# estuary-rpc-server

> Estuary RPC is a native-TS type safe RPC system for servers and browser clients - this is the server specific implementation

Latest version **1.1.0** (published 2026-10-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install estuary-rpc-server
pnpm add estuary-rpc-server
yarn add estuary-rpc-server
bun add estuary-rpc-server
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2026-10-23 |
| First published | 2022-08-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 102 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Nolan Hawkins |
| Maintainers | nolanhhawkins |
| Keywords | rpc, server, websocket |

## Links

- npm: https://www.npmjs.com/package/estuary-rpc-server
- Repository: https://github.com/digitaltembo/estuary-rpc
- Issues: https://github.com/digitaltembo/estuary-rpc/issues
- npm.io page: https://npm.io/package/estuary-rpc-server

## Dependencies (1)

- [estuary-rpc](https://npm.io/package/estuary-rpc.md) ^1.1.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2026-10-23
- 1.0.6 — 2022-08-24
- 1.0.5 — 2022-08-21
- 1.0.4 — 2022-08-20
- 1.0.3 — 2022-08-20
- 1.0.2 — 2022-08-20
- 1.0.1 — 2022-08-20

## README

# Estuary RPC Server

Estuary RPC is an attempt to make an extremely simple (toy) RPC system for use between browsers and servers that:

- is typesafe, with all types simply defined in TS - meaning your code won't compile if the server or the client code is not invoked with the correct types for the given RPC call
- supports most desired operations between client and server (REST methods, status codes, file uploads, automatic authentication)
- doesn't have external dependencies

# This Package

`estuary-rpc-server` defines the [createApiServer](http://digitaltembo.github.io/estuary-rpc/functions/estuary_rpc_server.createApiServer.html) method for translating your API metadata definition into a and typesafe collection of async functions organized into a functioning HTTP and WS server

# Installation
This should be installed in your server project
```
npm install estuary-rpc-server
```

# Usage

After following instructions for your common code, on the serverside, you need to instantiate an object that implements your Api with an ApiContext closure (so your endpoints can have access to the raw request/response and helper error methods) and an unknown metadata:
```ts
const server: ExampleApi<ApiContext, unknown> = {
  foo: {
    emptyPost: async () => {
      console.log("got post");
    },
    simpleGet: async (num: number) => 4,
    simpleStream: async ({ server }: Duplex<string, boolean>) => {
      server.on("message", (input: string) => {
        console.log("Got message", input);
        server.write(input === "foo");
      });
    },
  } as FooService<ApiContext, unknown>,

  fileUpload: (_1: void, _2: ApiContext) => {
    return null;
  },
};
```

Likely, of course, your individual services will be defined in separate files and/or directories, but they all still need to come together at the end. 

After you have a server object, to actually run it in such a way as to respond correctly to REST and WS connections, you simply need to `import { createApiServer } from "estuary-rpc-server";` and call it with your server definition and api metadata definition, as well as the port number on which you want to serve it
```ts
createApiServer(server, exampleApiMeta, { port: 8888} );
```
and the server will listen correctly!

---
_Source: https://npm.io/package/estuary-rpc-server · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
