Package Exports
- ts-procedures
- ts-procedures/client
- ts-procedures/codegen
- ts-procedures/express-rpc
- ts-procedures/hono-api
- ts-procedures/hono-rpc
- ts-procedures/hono-stream
- ts-procedures/http
- ts-procedures/http-docs
- ts-procedures/package.json
Readme
ts-procedures
A TypeScript RPC framework that creates type-safe, schema-validated procedure calls with a single function definition. Define your procedures once and get full type inference, runtime validation and procedure documentation/configuration.
Installation
npm install ts-proceduresQuick Start
import { Procedures } from 'ts-procedures'
import { Type } from 'typebox'
// Create a procedures factory
const { Create } = Procedures()
// Define a procedure with schema validation
const { GetUser, procedure, info } = Create(
'GetUser',
{
description: 'Fetches a user by ID',
schema: {
params: Type.Object({ userId: Type.String() }),
returnType: Type.Object({ id: Type.String(), name: Type.String() }),
},
},
async (ctx, params /* typed as { userId: string } */) => {
// returnType is inferred as { id: string; name: string }
return { id: params.userId, name: 'John Doe' }
},
)
// Call the procedure directly
const user = await GetUser({}, { userId: '123' })
// Or use the generic reference
const user2 = await procedure({}, { userId: '456' })Features
Core Procedures — Type-safe procedure definitions with
Procedures(),Create, andCreateStream. Includes schema validation (Suretype / TypeBox), error handling, generics, testing patterns, and the full API reference.Streaming — Async generator procedures with yield validation, abort signal integration, SSE examples, and stream error handling.
HTTP Integrations — Express and Hono builders with lifecycle hooks, route documentation,
DocRegistryfor composing docs, and per-channel input validation.Client Code Generation — Generate type-safe client SDKs from your server's
DocRegistry. CLI and programmatic API, adapters, hooks, streaming support, and self-contained mode.AI Agent Setup — Built-in configuration for Claude Code, Cursor, and GitHub Copilot. Auto-updates on
npm install.
Full documentation is available on GitHub.
License
MIT