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

blossom-mock-server

v0.1.0

Published

In-memory Blossom mock server for deterministic JavaScript tests.

Readme

blossom-mock-server

In-memory Blossom mock server for deterministic JavaScript and TypeScript tests.

Use it when your app or package needs to test Blossom blob upload and retrieval behavior without depending on an online server, network state, remote data, moderation policy, rate limits, authentication, or persistence.

Features

  • HTTP Blossom server interface for tests.
  • In-memory storage per server instance.
  • BUD-01 blob retrieval: GET /<sha256> and HEAD /<sha256>.
  • Optional file extensions on retrieval URLs.
  • BUD-02 blob upload: PUT /upload.
  • SHA-256 addressing over the exact uploaded bytes.
  • Blob descriptor responses with url, sha256, size, type, and uploaded.
  • Basic byte range support for GET.
  • CORS headers on all responses.
  • No auth, no persistence, no CLI.

Requirements

Node.js >=24.

Install

npm install blossom-mock-server

Usage

import { createMockBlossomServer } from "blossom-mock-server";

const server = createMockBlossomServer();

await server.start();

try {
  console.log(server.url); // http://127.0.0.1:<port>

  const response = await fetch(`${server.url}/upload`, {
    method: "PUT",
    headers: { "Content-Type": "text/plain" },
    body: "hello blossom"
  });

  console.log(await response.json());
} finally {
  await server.stop();
}

Test Example

import { createHash } from "node:crypto";
import { createMockBlossomServer } from "blossom-mock-server";

const server = createMockBlossomServer();
await server.start();

const data = new TextEncoder().encode("hello mock server");
const sha256 = createHash("sha256").update(data).digest("hex");

const upload = await fetch(`${server.url}/upload`, {
  method: "PUT",
  headers: {
    "Content-Type": "text/plain",
    "X-SHA-256": sha256
  },
  body: data
});

console.log(upload.status); // 201

const descriptor = await upload.json();
const download = await fetch(descriptor.url);

console.log(await download.text()); // hello mock server

API

createMockBlossomServer(options?)

Creates an isolated in-memory Blossom server instance.

const server = createMockBlossomServer({
  host: "127.0.0.1",
  port: 0
});

Options:

  • host?: string defaults to "127.0.0.1"
  • port?: number defaults to 0

Server methods:

  • await server.start() starts the HTTP server.
  • await server.stop() closes the HTTP server.
  • server.url is the server URL after start().
  • server.seed(blobs) inserts blobs into memory.
  • server.getBlobs() returns stored blobs.
  • server.getBlob(sha256) returns a stored blob by hash.
  • server.hasBlob(sha256) checks whether a blob exists.
  • server.reset() clears stored blobs.

Protocol Scope

This package implements a focused Blossom subset for tests.

Supported endpoints:

  • PUT /upload
  • GET /<sha256>
  • GET /<sha256>.<ext>
  • HEAD /<sha256>
  • HEAD /<sha256>.<ext>
  • OPTIONS *

Out of scope for v1:

  • BUD-11 Nostr authorization
  • BUD-12 DELETE /<sha256> and GET /list/<pubkey>
  • Mirror, media optimization, payment, rate limits, and persistence

License

MIT