A starter template for building Node.js applications with best practices and a clean architecture setup.
- 🚀 TypeScript Ready: Fully configured for TypeScript development.
- ⚡ Fastify Framework: A high-performance Node.js web framework.
- 🎨 Biome: Ensures consistent code style and quality.
- 🌍 Environment Management: Centralized
.envconfiguration usingdotenv. - ✅ Test-Ready: Integrated setup for unit and integration testing with
Vitest. - 🛠️ Clean Architecture: Organized project structure with a clear separation of concerns.
- 📄 Swagger API Documentation: Automatically generates API documentation using Swagger for easy integration and understanding of the endpoints.
-
Clone the repository:
git clone https://github.com/levi5/node-boilerplate.git cd node-boilerplate -
Install dependencies:
pnpm install
-
Set up environment variables: Create a
.envfile in the root directory based on the.env.examplefile:cp .env.example .env
-
Start the development server:
pnpm dev
| Script | Description |
|---|---|
pnpm start |
Run the application in production mode. |
pnpm dev |
Run the application in watch mode. |
pnpm build |
Build the application for production using tsup. |
pnpm test:unit |
Run unit tests using Vitest. |
pnpm test:integration |
Run integration tests using Vitest. |
pnpm coverage |
Generate a test coverage report using Vitest. |
node-boilerplate/
├── src/
│ ├── main/
│ │ ├── adapters/ # Custom adapters for integrating external modules
│ │ ├── factories/ # Factory functions for creating instances
│ │ ├── ports/ # Definitions of interfaces and abstract classes
│ │ ├── routes/ # Application routes configuration
│ │ └── app.ts # Main application entry point
│ ├── presentation/
│ │ ├── controllers/ # Controllers for handling HTTP requests
│ │ ├── protocols/ # Interfaces and contracts used in the presentation layer
│ ├── domain/ # Core business logic and entities
│ ├── infra/ # External frameworks, databases, and services
├── tests/ # Unit and integration tests
├── settings/
│ ├── tsup/ # TSUP build configurations
│ ├── vitest/ # Vitest configurations
├── .env.example # Example environment variables
├── package.json # Node.js dependencies and scripts
└── README.md # Project documentation
Contributions are welcome! Feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.