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

@counterfact/types

v0.1.0

Published

Shared TypeScript contracts for Counterfact generators, runtimes, middleware, and generated handlers.

Readme

@counterfact/types

This package contains the dependency-light TypeScript contracts shared by the Counterfact generator, runtime, middleware, and generated route handlers. It has no runtime dependencies on another Counterfact package.

Counterfact continues copying these source files into each generated project as counterfact-types/, so existing generated imports remain self-contained and do not require this package to be installed.

Files

| File | Description | | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | index.ts | Re-exports all public types from the individual files below | | cookie-options.ts | CookieOptions — options for setting an HTTP cookie (domain, path, maxAge, etc.) | | counterfact-response.ts | COUNTERFACT_RESPONSE — the terminal branded type returned by a completed response builder | | example.ts | Example — a named example entry from an OpenAPI document (summary, description, value) | | example-names.ts | ExampleNames<Response> — extracts the union of named example keys from an OpenAPI response | | generic-response-builder.ts | GenericResponseBuilderInner<Response> and GenericResponseBuilder<Response> — the strongly-typed fluent response builder generated for each route handler, along with its internal helper types (NeverIfEmpty, SchemasOf, MaybeShortcut, MatchFunction, HeaderFunction) | | http-status-code.ts | HttpStatusCode — union of all standard HTTP status code numbers | | if-has-key.ts | IfHasKey<SomeObject, Keys, Yes, No> — conditional type that resolves to Yes when SomeObject has a key matching any string in Keys | | maybe-promise.ts | MaybePromise<T> — a value that is either T or Promise<T> | | media-type.ts | MediaType — a string in the form type/subtype representing an IANA media type | | middleware.ts | Middleware<Context> and related request/response types for custom _.middleware.ts files | | omit-all.ts | OmitAll<T, K> — removes all keys from T whose names contain any string in K as a substring | | omit-value-when-never.ts | OmitValueWhenNever<Base> — strips keys from Base whose value type is never | | open-api-content.ts | OpenApiContent — a single content entry in an OpenAPI response (schema only) | | open-api-header.ts | OpenApiHeader — a single HTTP response header as modelled in an OpenAPI document | | open-api-operation.ts | OpenApiOperation — an HTTP operation (parameters, requestBody, responses) from an OpenAPI document | | open-api-parameters.ts | OpenApiParameters — a single parameter definition (path, query, header, etc.) from an OpenAPI document | | open-api-response.ts | OpenApiResponse and OpenApiResponses — a single HTTP response definition and a map of status codes to responses | | random-function.ts | RandomFunction — the type of the .random() method on the response builder | | response-builder.ts | ResponseBuilder — a loosely-typed chainable response builder for non-generated contexts | | response-builder-factory.ts | ResponseBuilderFactory<Responses> — maps status codes to their GenericResponseBuilder instances | | wide-operation-argument.ts | WideOperationArgument — the loosely-typed argument object for wide (catch-all) route handlers | | wide-response-builder.ts | WideResponseBuilder — a loosely-typed response builder for wide route handlers |

Usage

Focused-package consumers can import the shared contracts directly:

import type { Middleware, ResponseBuilder } from "@counterfact/types";

Generated Counterfact projects should keep using their local counterfact-types/ imports unless they deliberately choose a different dependency model.

See examples/middleware.ts for a complete public-import example that is type-checked by the package-closure harness.