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 🙏

© 2025 – Pkg Stats / Ryan Hefner

user-agent-402

v0.0.37

Published

This abstracted entry point:

Readme

User Agent 402 - Minimal Framework for Pay-as-you-Go Monetised Agent-First APIs

This abstracted entry point:

  1. Imports configuration from ./main with sensible defaults
  2. Handles CORS for all responses automatically
  3. Determines format (html/md) from Accept header or file extension
  4. Caches responses in both formats using versioned keys
  5. Applies rate limiting and billing using configurable values
  6. Converts markdown to HTML using the imported template
  7. Handles root path serving README.md or index.html
  8. Delegates to main handler for actual business logic

It has strong and powerful opinions built-in:

  • assume the stored KV is a value for the path+query+ext+version
  • KV-first: if kv is present, always use it. If not, the handler is hit. KV should contain the final HTML and final Markdown rather than structured data. This ensures results are always extremely fast by design.

One learning that can be taken from this package is the 'package-as-entrypoint' pattern; the package becomes the entrypoint while using files from the worker itself, and this works fine!

How to use:

  1. npm i user-agent-402
  2. Ensure you have result.html, main.js|ts in your repo
  3. inherit this toml
name = "your-repo"
compatibility_date = "2025-06-01"
main = "node_modules/user-agent-402/index.js"
dev.port = 3000
assets.directory = "./"
assets.binding = "ASSETS"

[[kv_namespaces]]
binding = "PATH_CACHE"
id = "your-path_cache-id"

[[durable_objects.bindings]]
name = "RATE_LIMITER"
class_name = "RateLimiter"

[[durable_objects.bindings]]
name = "DORM_NAMESPACE"
class_name = "DORM"

[[migrations]]
tag = "v1"
new_sqlite_classes = ["RateLimiter", "DORM"]

Ensure to have these secrets set:

STRIPE_WEBHOOK_SIGNING_SECRET=
STRIPE_SECRET=
STRIPE_PUBLISHABLE_KEY=
STRIPE_PAYMENT_LINK=
DB_SECRET=

In your main.js|ts ensure your default export has the following variables set (if you don't want them to be defaulted):

// all values are optional!
export default {
  // version for resolving values from kv
  version: 1,
  // cents to charge per 200 response for users that have paid
  priceCredit: 1,
  // requests per period until ratelimit is hit, per IP
  freeRatelimit: 10,
  // period in seconds after which ratelimit is reset
  freeRateLimitResetSeconds: 3600,

  // Your handler(s)
  fetch: (request) => {
    return new Response("Hello, world!");
  },
};