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

tannur

v0.2.0

Published

Official SDK for the Tannur Event-Sourced BaaS platform

Readme

Tannur SDK

Official TypeScript/JavaScript SDK for the Tannur Event-Sourced Backend-as-a-Service platform.

Installation

npm install tannur

Authentication

Option 1: CLI Login (Recommended)

# Install CLI globally
npm install -g @tannur/cli

# Authenticate (opens browser)
tannur login

# Now use SDK without API key
import { createClient } from "tannur";
const tannur = createClient(); // API key automatically resolved

Option 2: Manual API Key

# Register for API key
curl -X POST https://api.tannur.dev/register \
  -H "Content-Type: application/json" \
  -d '{"email":"[email protected]"}'
import { createClient } from "tannur";

const tannur = createClient({
  apiKey: "your-api-key-here"
});

Option 3: Environment Variable

export TANNUR_API_KEY="your-api-key-here"
import { createClient } from "tannur";
const tannur = createClient(); // Uses TANNUR_API_KEY env var

Quick Start

import { createClient } from "tannur";

// Initialize client (API key resolved automatically)
const tannur = createClient({
  baseUrl: "https://your-api.vercel.app" // optional, defaults to https://api.tannur.dev
});

// Emit an event
await tannur.emit("order_placed", {
  orderId: "order_123",
  customerId: "user_456",
  amount: 99.99,
  items: ["item1", "item2"]
});

// Query current state
const state = await tannur.getState("default");
console.log(state); // Current projected state

API Reference

createClient(config?)

Creates a new Tannur client instance.

Parameters:

  • config.apiKey (string, optional): Your tenant API key. If not provided, will be resolved from TANNUR_API_KEY environment variable or global config (~/.tannur/config)
  • config.baseUrl (string, optional): API base URL, defaults to https://api.tannur.dev

Returns: TannurClient

client.emit(eventName, payload, options?)

Emits an event to the event stream.

Parameters:

  • eventName (string): Name of the event (e.g., "order_placed", "user_registered")
  • payload (object): Event data
  • options.streamId (string, optional): Stream identifier, defaults to "default"

Returns: Promise<{ sequenceNumber: number, currentHash: string }>

Example:

const result = await tannur.emit("user_registered", {
  userId: "user_123",
  email: "[email protected]",
  plan: "premium"
}, { streamId: "users" });

console.log(`Event #${result.sequenceNumber} with hash ${result.currentHash}`);

client.getState(streamId)

Retrieves the current projected state for a stream.

Parameters:

  • streamId (string): Stream identifier

Returns: Promise<object> - The current state snapshot

Example:

const userState = await tannur.getState("users");
console.log(`Total users: ${userState.totalUsers}`);

Error Handling

The SDK throws TannurError for API errors:

import { TannurError } from "tannur";

try {
  await tannur.emit("", {}); // Invalid empty event name
} catch (error) {
  if (error instanceof TannurError) {
    console.log(`API Error ${error.status}: ${error.message}`);
  }
}

TypeScript Support

The SDK is written in TypeScript and includes full type definitions:

import { createClient, TannurClient, TannurConfig, EmitResult } from "tannur";

const config: TannurConfig = {
  apiKey: "your-key", // optional
  baseUrl: "https://your-api.vercel.app"
};

const client: TannurClient = createClient(config);
const result: EmitResult = await client.emit("test", { data: "value" });

CommonJS and ESM Support

The SDK supports both CommonJS and ES modules:

// CommonJS
const { createClient } = require("tannur");

// ES Modules
import { createClient } from "tannur";

License

MIT