npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ts-procedures

v8.0.0

Published

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 framework integration hooks.

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.

Goals of this Project

  1. Full type safety
  2. Auto generated documentation and client api spec
  3. Fast and performant
  4. Excellent DX (and agent documentation)

Installation

npm install ts-procedures

Quick 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' })

v8 Migration — Unified HonoAppBuilder

The three Hono builders (HonoRPCAppBuilder, HonoAPIAppBuilder, HonoStreamAppBuilder) are replaced in v8 by a single HonoAppBuilder that accepts any Procedures<>() factory and dispatches all four procedure kinds (rpc, rpc-stream, http, http-stream) by procedure.kind from a single register() call.

// Before (v7)
const rpc = new HonoRPCAppBuilder({ app, errors }).register(F1, ctx1)
const api = new HonoAPIAppBuilder({ app, errors, queryParser }).register(F2, ctx2)
const stream = new HonoStreamAppBuilder({ app, errors, onMidStreamError }).register(F3, ctx3)

// After (v8)
const builder = new HonoAppBuilder({
  app,
  errors,
  api: { queryParser },
  stream: { onMidStreamError },
}).register(F1, ctx1).register(F2, ctx2).register(F3, ctx3)

Kind-specific config knobs are stratified into rpc.*, api.*, and stream.* blocks. Single-app users can call builder.toDocEnvelope() directly (no DocRegistry needed). DocRegistry remains for multi-app aggregation.

Subpath imports change from ts-procedures/hono-rpc, ts-procedures/hono-api, ts-procedures/hono-stream to ts-procedures/hono.

HTTP Routes (v8) — CreateHttp

v8 introduces CreateHttp and CreateHttpStream as first-class HTTP creators. HTTP fields (path, method, scope, errors) live on the creator config directly; no factory type parameter is required.

import { Procedures } from 'ts-procedures'
import { HonoAppBuilder } from 'ts-procedures/hono'
import { Type } from 'typebox'

type AppContext = { userId: string }
const API = Procedures<AppContext>()

// Input channels: pathParams, query, body, headers (schema.req)
// Response: schema.res.body (docs) + schema.res.headers (makes handler return { body, headers })
API.CreateHttp('GetUser', {
  path: '/users/:id',
  method: 'get',
  schema: {
    req: { pathParams: Type.Object({ id: Type.String() }) },
    res: { body: Type.Object({ id: Type.String(), name: Type.String() }) },
  },
}, async (ctx, { pathParams }) => fetchUser(pathParams.id))

API.CreateHttp('CreateUser', {
  path: '/users',
  method: 'post',
  schema: {
    req: { body: Type.Object({ name: Type.String(), email: Type.String() }) },
  },
}, async (ctx, { body }) => createUser(body))

const app = new HonoAppBuilder({ pathPrefix: '/api' })
  .register(API, (c) => ({ userId: c.req.header('x-user-id') || 'anonymous' }))
  .build()
// GET /api/users/:id → 200, POST /api/users → 201

Migrating from v7? Replace Procedures<Ctx, APIConfig>()Procedures<Ctx>(), .Create(.CreateHttp(, and schema.inputschema.req. Then re-run npx ts-procedures-codegen. See CHANGELOG.md for the full breaking-changes list.

Features

  • Core Procedures — Type-safe procedure definitions with Procedures(), Create, CreateHttp, and CreateStream. Includes schema validation with 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. CreateHttpStream supports response headers via TypedStream.headers.

  • HTTP IntegrationsHonoAppBuilder with lifecycle hooks, route documentation, DocRegistry for composing docs, and per-channel input validation via schema.req.

  • 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.

  • Typed Error Handling — Declarative defineErrorTaxonomy maps thrown error classes to HTTP responses across every builder; generated clients throw typed class instances you can catch with instanceof.

  • Client Error Handling — Normalized framework error classes (ClientHttpError, ClientNetworkError, ClientTimeoutError, ClientAbortError, ClientParseError), .safe() Result API for exhaustive narrowing without try/catch, and augmentable ClientErrorMap for custom error categories.

  • 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