1.0.4 โข Published 8 months ago
fastify-create v1.0.4
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