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

@openknot-ts/fastify-server

v0.0.6-preview

Published

Fastify server lifecycle, plugin selection and draining for OpenKnot applications.

Readme

@openknot-ts/fastify-server

A Fastify host for native Fastify plugins. It owns the instance, listening and graceful draining as a Wire resource; plugins own their routes, parsing, hooks and errors. Fastify is a peer dependency, so the application and its plugins share one Fastify API.

Usage

import { fastifyHttp } from "@openknot-ts/fastify-server";
import { healthHttp } from "@openknot-ts/knot-health/fastify";
import { restFastify } from "@openknot-ts/knot-rest-fastify";
import { trpcFastify } from "@openknot-ts/trpc-fastify";
import { defineApplication } from "@openknot-ts/wire";

export const application = defineApplication({
  modules: [applicationModule, transport, fastifyHttp, trpcFastify, restFastify, healthHttp],
});

An application route is a plugin as well:

const hello = unit({
  provides: fastifyPlugins,
  factory: (): FastifyPlugin => async (instance) => {
    instance.get("/hello", async () => ({ hello: "world" }));
  },
});

API

| Export | Description | | --- | --- | | fastifyHttp | Ready module listing fastifyServer. | | fastifyServer | The default host: fastify() on PORT/HTTP_HOST. Resolves to { native, url, listening }. | | fastifyHttpServer({ requirements?, create, listen? }) | A host over the application's own instance. | | fastifyPlugins, FastifyPlugin | Collection of native callback or async plugins, registered in module order before listening. | | fastifyHttpConfig | The default host's environment configuration. |

Configuration

| Variable | Default | Meaning | | --- | --- | --- | | PORT | 3000 | TCP port; 0 picks a free port. | | HTTP_HOST | 127.0.0.1 | Bind address. |

Native instances

create(dependencies) builds the instance synchronously during acquisition, with every native option and inferred type: HTTPS, HTTP/2, serverFactory, loggers and type providers. listen(dependencies) returns native FastifyListenOptions (ports, Unix socket path, backlog, ipv6Only, signal) and replaces fastifyHttpConfig entirely.

const settings = config({
  FASTIFY_PORT: z.string().regex(/^\d+$/).transform(Number).pipe(z.int().min(0).max(65_535)),
  FASTIFY_HOST: z.string().default("127.0.0.1"),
});

const server = fastifyHttpServer({
  requirements: { settings, certificates },
  create: ({ certificates }) =>
    fastify({
      http2: true,
      https: { key: certificates.key, cert: certificates.cert, allowHTTP1: true },
      bodyLimit: 2_097_152,
    }),
  listen: ({ settings }) => ({ port: settings.FASTIFY_PORT, host: settings.FASTIFY_HOST }),
});

Select it with providePlugs([server]) instead of fastifyHttp; it can run beside a Node host that keeps PORT/HTTP_HOST. url is Fastify's listeningOrigin: an HTTP(S) address or a socket path.

Lifecycle

  • Plugins register during acquisition; a plugin that fails rejects startup and closes the instance, as does a cancelled startup.
  • A host whose plugins serve Flow exposures starts after Flow's listeners and drains before them.
  • Release closes the instance through Fastify. HTTP/1 responses in flight get Connection: close; HTTP/2 sessions follow Fastify.

Example and tests