create-fastify-oop-decorators
v1.0.0
Published
The official scaffolding CLI tool to quickly bootstrap a Fastify application using **[fastify-oop-decorators](https://github.com/WaRtr0/fastify-oop-decorators)**.
Readme
create-fastify-oop-decorators
The official scaffolding CLI tool to quickly bootstrap a Fastify application using fastify-oop-decorators.
Get a NestJS-like Developer Experience (DX) with the raw performance of Fastify in seconds.
Features
- Interactive CLI: A smooth, interactive prompt to configure your project.
- TypeScript Ready: Pre-configured
tsconfig.jsonwith strict mode,experimentalDecorators, andemitDecoratorMetadata. - Modular Architecture: Generates an enterprise-ready folder structure (Controllers, Services, Modules, and Plugins).
- Validation Options: Choose between native Fastify JSON schemas or class-based DTOs via ajv-decorators.
- Linter Support: Out-of-the-box configuration for ESLint or Biome.
- Package Manager Agnostic: Works flawlessly with
npm,pnpm,yarn, andbun.
Quick Start
The easiest way to get started is to use npx. Run the following command in your terminal:
npx create-fastify-oop-decorators@latest my-awesome-api
You will be prompted to choose your preferences:
- Which package manager to use?
- Would you like to use
ajv-decoratorsfor class-based DTO validation? - Which linter would you like to use (ESLint, Biome, or none)?
Once the setup is complete, navigate into your new project and start the development server:
cd my-awesome-api
npm run dev
Non-Interactive Mode (CLI Flags)
You can bypass the interactive prompts by passing command-line arguments. This is perfect for CI/CD environments or quick setups.
npx create-fastify-oop-decorators@latest my-api --use-pnpm --ajv --biome --yes
Available Options:
| Flag | Description |
| --- | --- |
| --use-npm | Explicitly use npm to install dependencies. |
| --use-pnpm | Explicitly use pnpm to install dependencies. |
| --use-yarn | Explicitly use yarn to install dependencies. |
| --use-bun | Explicitly use bun to install dependencies. |
| --ajv / --no-ajv | Include (or exclude) ajv-decorators for DTO validation. |
| --eslint | Initialize the project with an ESLint configuration. |
| --biome | Initialize the project with a Biome configuration. |
| --no-linter | Skip linter configuration entirely. |
| --yes | Use your previously saved preferences (or defaults) without prompting. |
| --reset-preferences | Clear the saved preferences from your machine. |
Generated Project Structure
By default, the CLI generates a modular, enterprise-ready architecture:
my-awesome-api/
├── src/
│ ├── hello/
│ │ ├── dto/
│ │ │ └── sayHelloPost.dto.ts # (If ajv-decorators is enabled)
│ │ ├── hello.controller.ts # Example Controller
│ │ ├── hello.module.ts # Module grouping Controller & Service
│ │ └── hello.service.ts # Example injectable Service
│ ├── plugins/
│ │ ├── ajv-decorators-plugin.ts # (If ajv-decorators is enabled)
│ │ └── bootstrap-plugin.ts # Fastify OOP injection setup
│ ├── app.module.ts # Root module
│ ├── build-app.ts # Fastify instance builder (Great for testing!)
│ └── index.ts # Entry point (Server listen)
├── package.json
├── tsconfig.json
└── eslint.config.mjs / biome.json # Depending on your linter choice
Available Scripts
Inside your newly created project, you can run:
npm run dev: Starts the application in watch mode usingtsx.npm run build: Compiles the TypeScript code into thedist/folder.npm start: Runs the compiled application.npm run lint: Runs your chosen linter (ESLint or Biome) to check your codebase.
Related Projects
- fastify-oop-decorators: The core library powering this architecture.
- ajv-decorators: Native Fastify JSON schemas generation using classes and decorators.
License
This project is licensed under the MIT License.
