1.0.4 โ€ข Published 8 months ago

fastify-create v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

create-fastify-api

Create type-safe Fastify applications with a single command. This package sets up a modern, production-ready Fastify project with TypeScript, TypeBox, and Swagger integration.

Quick Start

npx create-fastify-api my-api
cd my-api
npm run dev

Visit http://localhost:3000/docs to see your API documentation.

Features

โœจ What you get out of the box:

  • โšก๏ธ Fastify - High-performance web framework
  • ๐Ÿ”ท TypeScript - Type safety
  • ๐Ÿ“˜ TypeBox - Runtime type validation
  • ๐Ÿ“š Swagger UI - API documentation
  • โœ… Request/Response validation
  • ๐Ÿงช Built-in testing setup
  • ๐Ÿ“ OpenAPI generation

Usage

Create a New Project

# npm
npx create-fastify-api my-api

# yarn
yarn create fastify-api my-api

# pnpm
pnpm create fastify-api my-api

Options

npx create-fastify-api [project-name] [options]

Options:
  --package-manager   Choose package manager (npm, yarn, pnpm)
  --git              Initialize git repository (default: true)
  --install          Install dependencies (default: true)
  -h, --help         Show help
  -v, --version      Show version

Project Structure

The generated project follows a clean, maintainable structure:

my-api/
โ”œโ”€โ”€ api/
โ”‚   โ”œโ”€โ”€ routes.ts          # API route handlers
โ”‚   โ”œโ”€โ”€ server.ts          # Fastify server configuration
โ”‚   โ”œโ”€โ”€ server-start.ts    # Server startup script
โ”‚   โ””โ”€โ”€ generateOpenApi.ts # OpenAPI documentation generator
โ”œโ”€โ”€ types/
โ”‚   โ”œโ”€โ”€ ExampleRequest.ts  # Request type definitions
โ”‚   โ”œโ”€โ”€ ExampleResponse.ts # Response type definitions
โ”‚   โ””โ”€โ”€ ErrorResponse.ts   # Error response schemas
โ”œโ”€โ”€ package.json
โ””โ”€โ”€ tsconfig.json

Available Scripts

# Start development server
npm run dev

# Run tests
npm test

# Generate OpenAPI documentation
npm run generate-openapi

# Start production server
npm start

Template

This package uses fastify-template as the base template. Check out the template repository for more details about the implementation.

Contributing

We welcome contributions! Please feel free to submit a Pull Request.

License

MIT

Author

Gokhan KOC

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago