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

seiro

v0.1.10

Published

CQRS over WebSocket with Bun and Preact Signals

Readme

Seiro

CQRS over WebSocket with Bun and Preact Signals.

Installation

bun add seiro @preact/signals-core

Quick Start

Server

import { createServer } from "seiro/server";
import type { Command, Query } from "seiro";

type Commands = {
  "user.create": Command<{ name: string }, { id: number }>;
};

type Queries = {
  "users.all": Query<void, { id: number; name: string }>;
};

type Events = {
  "user.created": { id: number; name: string };
};

const server = createServer<Commands, Queries, Events>();

server.command("user.create", async (data, ctx) => {
  // Insert user into database
  const id = 1;
  server.emit("user.created", { id, name: data.name });
  return { id };
});

server.query("users.all", async function* (params, ctx) {
  // Stream users from database
  yield { id: 1, name: "Alice" };
  yield { id: 2, name: "Bob" };
});

server.start();

Client

import { createClient, signal, effect } from "seiro/client";

type Commands = {
  "user.create": Command<{ name: string }, { id: number }>;
};

type Queries = {
  "users.all": Query<void, { id: number; name: string }>;
};

type Events = {
  "user.created": { id: number; name: string };
};

const client = createClient<Commands, Queries, Events>("ws://localhost:3000/ws");

await client.connect();

// Send command with callbacks (server sends response)
client.cmd("user.create", { name: "Alice" }, {
  onSuccess: (result) => console.log("Created:", result.id),
  onError: (err) => console.error("Failed:", err),
});

// Fire-and-forget command (no callbacks, no response)
client.cmd("analytics.track", { event: "signup" });

// Query with streaming
for await (const user of client.query("users.all")) {
  console.log(user);
}

// Subscribe to events
client.on("user.created", (data) => {
  console.log("New user:", data);
});
client.subscribe();

Type System

Define your commands, queries, and events with full type safety:

import type { Command, Query } from "seiro";

// Command<Data, Result>
type MyCommands = {
  "entity.create": Command<{ name: string }, { id: number }>;
  "entity.delete": Command<{ id: number }, void>;
};

// Query<Params, Row>
type MyQueries = {
  "entities.all": Query<void, Entity>;
  "entities.byId": Query<{ id: number }, Entity>;
};

// Events are just payload types
type MyEvents = {
  "entity.created": Entity;
  "entity.deleted": { id: number };
};

Features

  • Type-safe: Full TypeScript support for commands, queries, and events
  • Streaming queries: Queries yield rows as they're fetched
  • Reactive: Built-in Preact Signals integration
  • Authentication: Token-based auth with public/private routes
  • Subscriptions: Pattern-based event subscriptions

Domain Modelling CLI

Design your CQRS system with the built-in modelling tool:

# Define entities
bunx seiro model add entity Product "A product in the catalogue"
bunx seiro model add attribute Product name string
bunx seiro model add attribute Product price integer

# Define documents (read models)
bunx seiro model add document Catalogue
bunx seiro model add doc-entity Catalogue Product
bunx seiro model add query Catalogue products "SELECT * FROM products"

# Define commands and events
bunx seiro model add command product.save
bunx seiro model add command-doc product.save Catalogue
bunx seiro model add event product_saved product.save

# Visualise with PlantUML diagrams
bunx seiro model up      # start PlantUML server (Docker)
bunx seiro model serve   # view diagrams at localhost:3000

# Export for code generation
bunx seiro model export  # outputs JSON

Run bunx seiro model --help for full CLI documentation.

License

MIT