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

@openally/servo

v1.1.0

Published

Zero-dependency static file and payload serving for Node.js

Readme

Requirements

Getting Started

Install with npm or yarn:

$ npm i @openally/servo
# or
$ yarn add @openally/servo

Usage example

servo() returns a Connect-style (req, res, next?) handler. It plugs into http.createServer directly:

import http from "node:http";
import { servo } from "@openally/servo";

http
  .createServer(servo("./dist", { maxAge: 3600 }))
  .listen(8080);

The same handler works in Vite, Polka or Express. Requests outside the prefix, and methods other than GET and HEAD, go to next():

import { compose, servo } from "@openally/servo";

server.middlewares.use(compose(
  servo("./editors/scene/dist", { prefix: "/editors/scene", dev: true }),
  servo("./editors/sprite/dist", { prefix: "/editors/sprite", dev: true })
));

/editors/scene answers 302 to /editors/scene/, which serves index.html.

Files do not have to live in a folder. bytesSource serves any async byte store, here with a content-hash ETag so reloads get 304s:

import { bytesSource, servo } from "@openally/servo";

const handler = servo(
  bytesSource((path) => store.read(path), { etag: "content" }),
  { prefix: "/assets", methodNotAllowed: "reject", index: false }
);

A single computed payload needs no source at all:

import { allowMethods, sendJson } from "@openally/servo";

function catalogHandler(req, res, next) {
  if (URL.parse(req.url ?? "", "http://localhost")?.pathname !== "/catalog.json") {
    return next();
  }
  if (allowMethods(req, res)) {
    sendJson(req, res, { body: catalog.snapshot(), etag: true });
  }
}

API

Path safety

The raw req.url is decoded once with decodeURIComponent and never goes through the WHATWG URL parser, which would silently collapse .. and %2e%2e. The decoded path is then checked in order:

| Check | Example | Status | | --- | --- | --- | | Malformed percent-encoding | /%E0%A4%A | 400 | | Control characters, %00 included | /a/%00.txt | 400 | | Absolute path or drive letter, after \ becomes / | //etc/passwd, /C:/win.ini | 403 | | Escapes the root once normalized | /..%2fpackage.json | 403 | | :, trailing . or space, Windows device name | /file.txt::$DATA, /con.txt, /index.html. | 403 | | Dotfile segment, .well-known excepted | /.git/config | 404 (dotfiles: "deny": 403) | | ignore(path) returns true | | 404 | | Real path leaves the real root (symlinks, junctions) | /escape/secret.txt | 404 |

The Windows rules apply on every platform, so a path rejected on Windows is also rejected on Linux. The downside: a file legitimately named a:b.txt on Linux cannot be served. rejectionStatus changes the first five statuses.

HTTP behavior

  • GET and HEAD, with ETag and Last-Modified revalidation. If-None-Match takes a list, *, and compares weakly.
  • Single byte ranges: bytes=a-b, bytes=a- and bytes=-n. Several ranges in one header are ignored, and the full file is sent with 200. A range that starts past the end answers 416.
  • If-Range needs a strong ETag or the exact Last-Modified date. The default ETags are weak, so for filesystem files it falls back to a full 200.
  • Precompressed .br and .gz siblings, chosen from Accept-Encoding q-values.
  • X-Content-Type-Options: nosniff on every file, and charset=utf-8 on every textual type.

Directory listings, on-the-fly compression, multipart ranges and write methods are out of scope.

License

MIT