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

@ioka-technologies/asyncapi-ts-client-template

v0.0.35

Published

TypeScript AsyncAPI client generator template compatible with rust-asyncapi patterns

Readme

AsyncAPI TypeScript Client Template

⚠️ Experimental: This template is still a work in progress and until we reach a 0.1.0 version, assume this is experimental and is not production ready.

Generate type-safe TypeScript clients from your AsyncAPI specifications with automatic transport selection and built-in error handling.

Overview

This template generates TypeScript clients that provide full type safety across the network boundary. The generated clients work seamlessly with AsyncAPI servers and automatically handle transport protocols, reconnection logic, and error recovery.

Key Benefits:

  • Type Safety: Full TypeScript types generated from your AsyncAPI spec
  • Transport Agnostic: Same API works over WebSocket or HTTP
  • Auto Reconnection: Built-in resilience for production environments
  • Zero Configuration: Works out of the box with sensible defaults

Technical Requirements

  • Node.js 16+
  • TypeScript 4.5+
  • AsyncAPI CLI 1.0+

Supported Transports

  • WebSocket (with auto-reconnection)
  • HTTP (with retry logic)

Quick Start

Installation

# Install AsyncAPI CLI
npm install -g @asyncapi/cli

# Generate your TypeScript client
asyncapi generate fromTemplate asyncapi.yaml @ioka-technologies/asyncapi-ts-client-template -o my-client

cd my-client
npm install
npm run build

Basic Usage

import { MyApiClient } from './my-client';

// WebSocket client with auto-reconnection
const client = new MyApiClient({
    transport: 'websocket',
    websocket: {
        url: 'wss://api.example.com',
        reconnect: true
    }
});

// Type-safe API calls
await client.connect();

// All methods are fully typed
const user = await client.createUser({
    name: "John Doe",     // TypeScript knows this is required
    email: "[email protected]",
    age: 30               // TypeScript knows this is optional
});

// Response is fully typed
console.log(user.id);        // TypeScript provides autocomplete
console.log(user.createdAt); // TypeScript knows this is a Date

// Real-time subscriptions
client.onUserCreated((user) => {
    console.log('New user:', user);
});

HTTP Transport

// HTTP client with retry logic
const client = new MyApiClient({
    transport: 'http',
    http: {
        baseUrl: 'https://api.example.com',
        retry: {
            attempts: 3,
            backoff: 'exponential'
        }
    }
});

const response = await client.getUser({ userId: '123' });

Authentication

// JWT Authentication
const client = new MyApiClient({
    transport: 'websocket',
    websocket: { url: 'wss://api.example.com' },
    auth: {
        jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
    }
});

// API Key Authentication
const client = new MyApiClient({
    transport: 'http',
    http: { baseUrl: 'https://api.example.com' },
    auth: {
        apiKey: {
            key: 'my-api-key-123',
            location: 'header',
            name: 'X-API-Key'
        }
    }
});

Template Configuration

Configure the template with parameters:

asyncapi generate fromTemplate asyncapi.yaml @ioka-technologies/asyncapi-ts-client-template \
  -o my-client \
  -p clientName=MyApiClient \
  -p packageName=my-api-client \
  -p packageVersion=1.0.0

| Parameter | Default | Description | |-----------|---------|-------------| | clientName | "{{info.title}}Client" | Main client class name | | packageName | "{{info.title | kebabCase}}-client" | NPM package name | | packageVersion | "{{info.version}}" | Package version | | author | "AsyncAPI Generator" | Package author | | transports | "websocket,http" | Supported transport protocols |

Error Handling

import { ConnectionError, MessageTimeoutError, HttpError } from './my-client';

try {
    await client.createUser(userData);
} catch (error) {
    if (error instanceof ConnectionError) {
        console.error('Connection failed:', error.message);
    } else if (error instanceof MessageTimeoutError) {
        console.error('Request timed out');
    } else if (error instanceof HttpError) {
        console.error(`HTTP ${error.status}: ${error.message}`);
    }
}

Generated Project Structure

my-client/
├── package.json              # NPM package configuration
├── tsconfig.json             # TypeScript configuration
├── src/
│   ├── index.ts              # Main exports
│   ├── client.ts             # Generated client class
│   ├── models.ts             # TypeScript interfaces
│   └── runtime/              # Transport implementations
└── examples/                 # Usage examples

Examples

See the examples directory for sample AsyncAPI specifications and generated clients.

Development

# Clone and test locally
git clone https://github.com/Ioka-Technologies/asyncapi-template.git
cd asyncapi-template/ts-client

# Run tests
npm test

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes and add tests
  4. Run the test suite: npm test
  5. Submit a pull request

License

Apache-2.0

Related Projects