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

@edgenets/fastify

v0.0.15

Published

Run Fastify on Firebase Functions with common plugins (CORS, Helmet, etc.)

Readme

My Fastify Server

A configurable Fastify server creation utility, providing common plugins out of the box (such as form body parsing, CORS, and Helmet). It also supports an optional typeProvider for enhanced TypeScript type checking in routes. Ideal for high-concurrency environments.

Features

  1. Quick Start
    Create a Fastify instance with a single function call: createFastifyServer(...).
  2. Common Plugins
    Integrates [@fastify/formbody], [@fastify/cors], and [@fastify/helmet] by default, reducing repetitive setup.
  3. Optional Type Providers
    Supports withTypeProvider() for seamless schema-to-type inference in TypeScript (e.g., using @fastify/type-provider-typebox).
  4. High Concurrency
    Fastify itself is designed for high-performance, I/O-intensive scenarios. Paired with environments like Node 18+ or Firebase Functions (Gen2), it can handle multiple concurrent requests efficiently.
  5. TypeScript-First
    Written in TypeScript and publishes .d.ts files for comprehensive type definitions.

Installation

npm install my-fastify-server
# or
pnpm add my-fastify-server
# or
yarn add my-fastify-server

Quick Usage


import { createFastifyServer } from 'my-fastify-server';

async function main() {
  // 1. Create the Fastify instance
  const app = createFastifyServer({
    logger: {
      level: 'info',
      formatters: { level: (label) => ({ level: label }) },
    },
  });

  // 2. Register a sample route
  app.get('/ping', async (request, reply) => {
    return { pong: true };
  });

  // 3. Start the server
  try {
    await app.listen({ port: 3000 });
    console.log('Server started at http://localhost:3000');
  } catch (err) {
    app.log.error(err);
    process.exit(1);
  }
}

main();

When you open http://localhost:3000/ping, you should see { "pong": true }.


Using a Custom Type Provider

To leverage @fastify/type-provider-typebox or other type providers for enhanced schema-based type inference:

import { createFastifyServer } from 'my-fastify-server';
import { TypeBoxTypeProvider } from '@fastify/type-provider-typebox';

async function main() {
  const app = createFastifyServer({
    logger: {
      level: 'info',
      formatters: { level: (label) => ({ level: label }) },
    },
    // Pass your chosen type provider here
    typeProvider: TypeBoxTypeProvider(),
  });

  // Using withTypeProvider to define strongly-typed routes
  const typedApp = app.withTypeProvider<TypeBoxTypeProvider>();

  typedApp.route({
    method: 'POST',
    url: '/echo',
    schema: {
      body: {
        type: 'object',
        properties: {
          msg: { type: 'string' },
        },
        required: ['msg'],
      },
      response: {
        200: {
          type: 'object',
          properties: {
            echo: { type: 'string' },
          },
        },
      },
    },
    handler: async (request, reply) => {
      return { echo: request.body.msg };
    },
  });

  await app.listen({ port: 3000 });
  console.log('Server with custom type provider is running on http://localhost:3000');
}

main();