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

@a_jackie_z/fastify-types

v1.0.1

Published

Type definitions and schemas for Fastify API contracts - frontend compatible

Readme

@a_jackie_z/fastify-types

Frontend-compatible type definitions and schemas for Fastify API contracts. This package provides essential types, response schemas, and utilities that can be safely imported in React applications and other frontend environments.

Installation

npm install @a_jackie_z/fastify-types

Features

  • Frontend Compatible: No Node.js dependencies - works in browsers and React apps
  • TypeScript Support: Full TypeScript definitions included
  • Zod Integration: Response schemas compatible with Zod validation
  • Tree Shakeable: Import only what you need

Exports

Response Types

import { 
  SuccessResponse, 
  ErrorResponse, 
  ValidationDetail,
  formatSuccess,
  formatError,
  successResponseSchema,
  errorResponseSchema
} from '@a_jackie_z/fastify-types'

// Type-safe response handling
const response: SuccessResponse<{ message: string }> = formatSuccess(200, { 
  message: 'Hello World' 
})

// Zod schema validation
const UserResponseSchema = successResponseSchema(z.object({
  id: z.string(),
  username: z.string()
}))

JWT Types

import { 
  TokenTypeConfig, 
  JwtAlgorithm,
  SignTokenOptions,
  VerifyTokenOptions,
  parseJwtSecrets
} from '@a_jackie_z/fastify-types'

// JWT configuration
const tokenConfig: TokenTypeConfig = {
  headerName: 'authorization',
  expiresIn: '15m',
  algorithm: 'HS256',
  iss: 'my-service'
}

// Parse secrets from environment
const secrets = parseJwtSecrets('key1=secret1|key2=secret2')

Error Handling

import { 
  createError, 
  HTTP_STATUS_CODES,
  HttpStatusCode 
} from '@a_jackie_z/fastify-types'

// Create client-side errors with status codes
const error = createError({
  statusCode: HTTP_STATUS_CODES.NOT_FOUND,
  message: 'User not found'
})

Differences from @a_jackie_z/fastify

This package is a frontend-compatible subset of the main @a_jackie_z/fastify package:

✅ Included:

  • Response types and formatters
  • JWT configuration types
  • Error types and utilities
  • Zod schemas for API contracts

❌ Excluded:

  • Fastify server instances and plugins
  • JWT signing/verification functions
  • Node.js crypto utilities
  • Server-specific middleware

Usage with React

// api/types.ts
import type { SuccessResponse, ErrorResponse } from '@a_jackie_z/fastify-types'

export type UserApiResponse = SuccessResponse<{
  id: string
  username: string
  email: string
}>

// hooks/useApi.ts
import { successResponseSchema, errorResponseSchema } from '@a_jackie_z/fastify-types'

const UserSchema = successResponseSchema(z.object({
  id: z.string(),
  username: z.string(),
  email: z.string().email()
}))

// Type-safe API response validation
const response = UserSchema.parse(await fetch('/api/users').then(r => r.json()))

License

MIT