# elixir_ts_rpc v0.0.2 - Table of Contents

Foundation for typed RPC procedures with TypeScript-compatible type resolution from @spec

## Pages

- [elixir_ts_rpc](readme.md)
- [Changelog](changelog.md)

- Guides
  - [Getting started](getting-started.md)
  - [Plug options](plug-options.md)
  - [Writing middleware](middleware.md)
  - [Supported types](supported-types.md)
  - [Handling errors](errors.md)
  - [Custom types](custom-types.md)

## Modules

- [RpcElixir](RpcElixir.md): Elixir server library for [elixir-ts-rpc](https://github.com/ostatni5/elixir-ts-rpc) —
a typed RPC layer between Elixir and TypeScript. Pre-1.0, so APIs may change.
Start with [Getting started](getting-started.md).

- Defining procedures
  - [RpcElixir.Context](RpcElixir.Context.md): Request-scoped context threaded through middleware and into handlers.
  - [RpcElixir.Handler](RpcElixir.Handler.md): Captures `@spec` and `@type` ASTs at handler-compile time. Exposes them
through the `__rpc_specs__/0` and `__rpc_types__/0` accessors.
  - [RpcElixir.Middleware](RpcElixir.Middleware.md): Behaviour for procedure middleware.
  - [RpcElixir.Middleware.Assign](RpcElixir.Middleware.Assign.md): Built-in middleware that puts static values into `ctx.assigns`.
  - [RpcElixir.Resolution](RpcElixir.Resolution.md): Envelope threaded through the middleware pipeline for a single procedure
invocation. Middleware receive and return a `%Resolution{}`.
  - [RpcElixir.Router](RpcElixir.Router.md): Macro-based DSL for defining RPC procedures in a router module. See
[Getting started](getting-started.md) for the surrounding setup.

- Serving requests
  - [RpcElixir.Dispatcher](RpcElixir.Dispatcher.md): Core dispatch pipeline: lookup → middleware → validate input → invoke handler →
validate output → serialize.
  - [RpcElixir.Plug](RpcElixir.Plug.md): HTTP transport adapter for `RpcElixir`, implemented as a `Plug`.
  - [RpcElixir.RpcError](RpcElixir.RpcError.md): Structured error returned from the dispatcher pipeline.
`RpcElixir.Dispatcher` owns the promotion rules for typed handler errors.
See [Handling errors](errors.md) for the guide.

- Types
  - [RpcElixir.CustomType](RpcElixir.CustomType.md): Teaches the library about a type it does not know.
  - [RpcElixir.Types](RpcElixir.Types.md): Type system for RPC procedure input and output specs.
  - [RpcElixir.Types.FromInferred](RpcElixir.Types.FromInferred.md): EXPERIMENTAL backend. It reads signatures inferred by Elixir's set-theoretic
type system. The source is the `ExCk` BEAM chunk, not user-written `@spec`.
  - [RpcElixir.Types.FromSpec](RpcElixir.Types.FromSpec.md): Reads classic `@spec` declarations from a compiled module's BEAM debug info,
via `Code.Typespec`. Translates them into the internal `%{kind: ...}` IR used
by handlers, routers, and codegen.
  - [RpcElixir.UnixMillis](RpcElixir.UnixMillis.md): Built-in branded-number custom type. A `DateTime` crosses the wire as epoch
milliseconds. The emitted TypeScript brand is `EpochMillis`
(`number & { readonly __brand: "EpochMillis" }`). It stops callers passing a
bare number where an instant is expected.

- Codegen
  - [RpcElixir.Codegen](RpcElixir.Codegen.md): Generates the TypeScript client from an RPC router.
  - [RpcElixir.Watcher](RpcElixir.Watcher.md): Dev-only GenServer that triggers recompilation on router source changes.

## Mix Tasks

- Codegen
  - [mix compile.elixir_ts_rpc](Mix.Tasks.Compile.ElixirTsRpc.md): Mix compiler that regenerates the TypeScript client on recompile.
  - [mix rpc.gen.ts](Mix.Tasks.Rpc.Gen.Ts.md): Generates a TypeScript client file from a router module.
  - [mix rpc.gen.ts.watch](Mix.Tasks.Rpc.Gen.Ts.Watch.md): Watches Elixir sources and regenerates the TypeScript client on change.

