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

@gasket/template-api-fastify

v7.0.8

Published

Gasket API template for Fastify

Readme

Gasket API Fastify Template

A high-performance TypeScript API template built with Gasket and Fastify.

Overview

This template provides a minimal, well-structured starting point for building RESTful APIs using:

  • Fastify - Fast and low overhead web framework for Node.js
  • TypeScript - Type-safe development with modern JavaScript features
  • Gasket - Plugin architecture for extensible applications
  • Swagger/OpenAPI - Automatic API documentation generation
  • Winston - Production-grade logging
  • Vitest - Lightning-fast unit testing

Features

  • TypeScript configuration with ES modules support
  • Fastify server with high-performance request handling
  • Swagger documentation auto-generated from JSDoc comments
  • Structured logging with Winston
  • Testing setup with Vitest and coverage reporting
  • Development server with hot reloading via tsx
  • Build pipeline for production deployment
  • ESLint configuration with GoDaddy style guide

Quick Start

Create a new API project using this template:

npx create-gasket-app@latest my-api --template @gasket/template-api-fastify

Project Structure

my-api/
├── gasket.ts              # Gasket configuration
├── server.ts              # Server entry point
├── plugins/               # Custom Gasket plugins
│   └── routes-plugin.ts   # API route definitions
├── swagger.json           # OpenAPI schema (generated)
├── test/                  # Test files
├── tsconfig.json          # TypeScript configuration
└── dist/                  # Built JavaScript (after npm run build)

Available Scripts

| Script | Description | |--------|-------------| | npm run local | Start development server with hot reload | | npm run build | Build TypeScript to JavaScript | | npm run start | Start production server from built files | | npm run test | Run unit tests | | npm run test:watch | Run tests in watch mode | | npm run test:coverage | Run tests with coverage report | | npm run docs | Generate and serve API documentation | | npm run lint | Check code style and quality |

API Routes

The template includes a sample route to get you started:

GET /default

Returns a welcome message.

Response:

{
  "message": "Welcome to your default route..."
}

Adding New Routes

Define routes in plugins/routes-plugin.ts using the fastify lifecycle:

export default {
  name: 'routes-plugin',
  hooks: {
    fastify(gasket, app) {
      /**
       * @swagger
       * /users:
       *   get:
       *     summary: Get all users
       *     responses:
       *       200:
       *         description: List of users
       */
      app.get('/users', async (req, res) => {
        res.send({ users: [] });
      });
    }
  }
};

Configuration

The template includes these Gasket plugins by default:

  • @gasket/plugin-fastify - Fastify server integration
  • @gasket/plugin-https - HTTPS and server lifecycle management
  • @gasket/plugin-swagger - OpenAPI documentation generation
  • @gasket/plugin-winston - Structured logging
  • @gasket/plugin-command - CLI command support

Additional plugins can be loaded dynamically via the commands configuration in gasket.ts.

Why Fastify?

Fastify offers several advantages over Express:

  • Performance - Up to 30,000 requests per second, nearly twice as fast as Express
  • Type Safety - Built with TypeScript in mind with excellent type definitions
  • Schema Validation - Built-in JSON schema validation for requests and responses
  • Plugin Architecture - Encapsulated plugin system with dependency management
  • Modern Features - Async/await support, HTTP/2, and built-in logging

Documentation

Run npm run docs to generate interactive API documentation using Swagger UI. The docs are automatically generated from JSDoc comments in your route handlers.

Testing

The template includes Vitest for testing. Write tests in the test/ directory:

import { describe, it, expect } from 'vitest';

describe('API Routes', () => {
  it('should return welcome message', () => {
    // Your test code here
  });
});

Next Steps

  • Add your API routes in plugins/routes-plugin.ts
  • Configure database connections and models
  • Set up authentication and authorization
  • Add input validation using Fastify's schema validation
  • Configure environment-specific settings
  • Set up CI/CD pipeline