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

@prefabs.tech/fastify-config

v0.94.1

Published

Fastify config plugin

Readme

@prefabs.tech/fastify-config

A Fastify plugin that provides opinionated, typed configuration management for APIs.

Why This Plugin?

In a complex API or monorepo with multiple Fastify plugins and services, maintaining a standardized configuration structure is critical. This plugin enforces a consistent config shape across services, centralizes config access at both the instance and request level, and provides a lightweight utility for parsing environment variables — without pulling in heavy validation dependencies like zod or ajv.

Why not Zod or @fastify/env?

  1. No runtime validation overhead — if your infrastructure (CI/CD, Docker, Kubernetes) guarantees correct environment variable injection, strict runtime validation is unnecessary overhead.
  2. Lightweight footprint — no ajv or zod means less bundle size and fewer transitive dependencies.
  3. Manual type definitions — hand-crafted TypeScript interfaces give immediate IDE support across your monorepo without extra build steps.

What You Get

Added by This Plugin

  • fastify.config — decorates the Fastify instance with your ApiConfig object, accessible everywhere on the instance
  • request.config — decorates every incoming request with the same config reference via an onRequest hook (useful for mercurius buildContext, route handlers, etc.)
  • fastify.hostname — computed ${baseUrl}:${port} string, derived from your config
  • parse(value, fallback) — type-coercing env var parser: returns a boolean, number, or string based on the fallback type; returns the fallback when the value is undefined
  • ApiConfig type — strongly typed interface covering app identity, origins, logging (pino), pagination, REST feature flag, and multi-tenant app list
  • AppConfig type — per-app shape for multi-tenant configurations (id, name, origin, supportedRoles)

Full feature list · Developer guide

Requirements

Peer dependencies (must be installed separately):

No sibling @prefabs.tech plugins need to be registered before this one.

Quick Start

// config.ts
import { parse } from "@prefabs.tech/fastify-config";
import type { ApiConfig } from "@prefabs.tech/fastify-config";

const config: ApiConfig = {
  appName: process.env.APP_NAME as string,
  appOrigin: (process.env.APP_ORIGIN as string).split(","),
  baseUrl: process.env.BASE_URL as string,
  env: parse(process.env.NODE_ENV, "development") as string,
  logger: { level: parse(process.env.LOG_LEVEL, "error") as string },
  name: process.env.NAME as string,
  port: parse(process.env.PORT, 3000) as number,
  protocol: parse(process.env.PROTOCOL, "http") as string,
  rest: { enabled: parse(process.env.REST_ENABLED, true) as boolean },
  version: `${process.env.npm_package_version}+${process.env.BUILD_ID || "local"}`,
};

export default config;
// server.ts
import configPlugin from "@prefabs.tech/fastify-config";
import Fastify from "fastify";
import config from "./config";

const fastify = Fastify({ logger: config.logger });
await fastify.register(configPlugin, { config });

await fastify.listen({ port: config.port, host: "0.0.0.0" });

Installation

Install with npm:

npm install @prefabs.tech/fastify-config

Install with pnpm:

pnpm add @prefabs.tech/fastify-config