A simple CLI to create a structured Fastify project with pre-configured files and folders for rapid development.
- Generates a project boilerplate with Fastify as the web framework.
- Includes setup for plugins, routes, controllers, services, and models.
- Automatically updates package.json with the project name.
- Supports .env and .gitignore creation.
Node.js (version 12 or higher)
To create a new Fastify project:
npm install -g fastify-boilerplate-cli
fastify-boilerplate-cli create <project-name>
Replace with the desired name for your new project. This will:
- Create a new directory with the given project name.
- Copy all boilerplate files into the new directory.
- Update package.json with the project name
This command will create a new folder named <project-name>
with the following structure:
<project-name>/
├── src/
│ ├── plugins/
│ ├── routes/
│ ├── controllers/
│ ├── services/
│ ├── models/
│ ├── utils/
│ ├── config/
│ ├── app.js
│ └── index.js
├── tests/
├── .env
├── .gitignore
├── package.json
└── README.md
-
src/: Contains all application source code, structured by plugins, routes, controllers, services, and models.
- app.js: Entry file for configuring Fastify and registering plugins and routes.
- config/: Stores configuration files like database configuration.
- plugins/: Custom Fastify plugins (e.g., authentication, database).
- routes/: Route definitions and schema validations.
- controllers/: Controllers for handling route logic.
- services/: Service layer for business logic.
- models/: Data models (if using an ORM).
- utils/: Utility functions (e.g., logger, error handler).
- tests/: Contains all application tests.
fastify-boilerplate-cli route <route-name>
It will create <route-name>
folder in routes, services and controllers. Also it will automatically register this route
in app.js.
This project is licensed under the MIT License.