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

@staffetta/server

v0.2.0

Published

Server side of the staffetta speedtest: stream primitives, a Web-standard fetch handler and a Node http adapter. Framework-agnostic.

Readme

@staffetta/server

Server side of the staffetta speedtest: stream primitives, a Web-standard fetch handler and a Node http adapter. Framework-agnostic — no third-party measurement servers, you mount three endpoints on your own backend and measure the path your users actually use.

Install

npm install @staffetta/server

Fetch-based runtimes (Hono, Next.js, Bun, Deno, Workers…)

import {createSpeedtestFetchHandler} from '@staffetta/server'

const speedtest = createSpeedtestFetchHandler()

// Hono
app.all('/speedtest/*', c => speedtest(c.req.raw))

// Next.js — app/speedtest/[[...slug]]/route.ts
export const GET = speedtest
export const POST = speedtest

Node http / Express

import {createServer} from 'node:http'
import {createSpeedtestNodeListener} from '@staffetta/server/node'

createServer(createSpeedtestNodeListener()).listen(8080)

// Express
app.use(createSpeedtestNodeListener())

Express / NestJS / Fastify middleware

createSpeedtestNodeMiddleware is the pass-through variant of the listener: requests outside the three protocol endpoints fall through to next(), so it composes with the rest of the application without claiming a route prefix. Register it globally (mounting it under a sub-path would strip the prefix the URL is matched against).

import {createSpeedtestNodeMiddleware} from '@staffetta/server/node'

// Express
app.use(createSpeedtestNodeMiddleware())

// NestJS — main.ts (Express adapter, or Fastify via @fastify/middie)
const app = await NestFactory.create(AppModule)
app.use(createSpeedtestNodeMiddleware())

The middleware handles the endpoints before the framework's routing and body parsing, which is what you want on the measured path: no interceptor, guard or JSON body parser adds latency to ping or buffers the upload stream.

Options

createSpeedtestFetchHandler({
  basePath: '/speedtest',        // path prefix of the three endpoints
  maxSizeBytes: 209_715_200,     // per-transfer cap (200 MiB)
  authorize: (request, phase) => checkToken(request), // download/upload only; ping stays anonymous
})

authorize never runs for ping — the ping endpoint is anonymous by design, so the client measures pure network RTT instead of auth + session time. For anything stronger, wrap the handler with your own middleware.

Raw primitives

If you'd rather wire the endpoints into your own controllers (NestJS, Fastify, anything):

import {createDownloadStream, consumeUploadStream} from '@staffetta/server'

createDownloadStream(sizeBytes)                    // ReadableStream of incompressible bytes
await consumeUploadStream(body, {maxBytes})        // → {bytesReceived, serverElapsedMs}

The endpoints implement an open protocol — any client speaking it can measure this server, and the @staffetta/client engine can measure any server implementing it. Protocol spec and methodology: github.com/staffetta/staffetta.

License

MIT