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

@krizaka/contract

v0.1.0

Published

Declare a response contract once (zod) and assert it everywhere the answer is acted on: route tests, journeys, synthetic monitors and the fetch wrappers of runtime boundaries. A 204 with no body, a missing field, an undefined or NaN count, an empty string

Readme

@krizaka/contract

Declare a response contract once (zod), assert it everywhere the answer is acted on: route tests, journeys, synthetic monitors and the fetch wrappers of runtime boundaries. ADR-022 (krizaka-internal#1969), slice #1971.

Why. « Sent to undefined of undefined » and every « 204 = success » share one class of defect: a response without the fields its caller reads passed. One schema per response, asserted in three places.

import { z } from "zod";
import { count, defineContract, expectProviderAnswer, fetchContract, nonEmptyList, text } from "@krizaka/contract";

// 1. Declare it once, export it.
export const newsletterSend = defineContract(
  "newsletter send",
  z.object({ sent: count(), total: count(), ids: nonEmptyList(text()) }),
);

// 2. Route / integration test: 2xx, JSON body, schema — else it throws with the field's path.
const body = await newsletterSend.expect(response);

// 3. Runtime boundary: the fetch wrapper fails on network error, non-2xx, empty or non-JSON body, missing field.
const result = await fetchContract(fetch, url, { method: "POST", body }, newsletterSend);

// Provider calls we act on (mail, payments, storage): accepted count >= 1 (or exactly what we sent) and the provider's id.
await expectProviderAnswer(response, z.object({ id: text(), accepted: count() }), {
  expectedAccepted: recipients.length,
});

What fails

  • a non-2xx status; a 204 or any empty body; a body that is not JSON;
  • a missing field, a wrong type; an undefined or NaN anywhere in the answer (even under z.unknown());
  • an empty string (pass allowEmptyStrings: true, or declare .optional(), where it is legitimate);
  • count(): a finite integer >= 0; nonEmptyList(item): at least one item; text(): a non-empty trimmed string.

Every failure is a ContractError with issues: { path, message }[] (recipients.1, total) and status. Values and URLs are never put in the message — an answer or a URL may carry a secret.

Exports

defineContract, expectContract, assertContract, expectProviderAnswer, fetchContract, ContractError, and the builders text, count, nonEmptyList. zod >= 4 is a peer dependency. Java services keep orazaka-contracts (httpyac).