π― An opinionated, production-ready NestJS boilerplate with TypeScript, PostgreSQL, and modern development tools
This project is based on the amazing work by Narek Hakobyan π¦π²
Original Repository: awesome-nest-boilerplate β
Special thanks to Narek for creating such a comprehensive and well-structured NestJS boilerplate that serves as the foundation for this project.
- π’ Node.js 20+
- π³ Docker + Docker Compose
- π¦ Yarn -
npm i -g yarn
Technology | Version | Purpose |
---|---|---|
ποΈ NestJS | v11.1.2 | Progressive Node.js framework |
πͺ TypeScript | v5.8.3 | Strongly typed JavaScript |
ποΈ TypeORM | v0.3.24 | Database ORM |
π PostgreSQL | Latest | Primary database |
π ESLint | v9.27.0 | Code linting with flat config |
π¨ Prettier | v3.5.3 | Code formatting |
πΊ Husky | v9.1.7 | Git hooks for code quality |
π§ͺ Jest | v29.7.0 | Testing framework |
π Swagger | v11.2.0 | API documentation |
π JWT | v11.0.0 | Authentication |
# 1. Clone this project
git clone https://github.com/moinulse/awesome-nest-boilerplate {your project name}
# 2. Enter your newly-cloned folder
cd your-project-name
# 3. Create Environment variables file
cp .env.example .env
# 4. Install dependencies
yarn
# 5. Run DB
docker compose up
# 4. Run development server and open http://localhost:3000
yarn watch:dev
# Alternative development start
yarn start:dev
# View API documentation (Swagger)
# Navigate to: http://localhost:3000/documentation
# Run linting
yarn lint
# Fix linting issues automatically
yarn lint:fix
# Run tests
yarn test
# Run tests in watch mode
yarn test:watch
# Run tests with coverage
yarn test:cov
# Run e2e tests
yarn test:e2e
# Generate a new migration
yarn migration:generate ./src/database/migrations/{migration-name}
# Example: Add post table
yarn migration:generate ./src/database/migrations/add-post-table
# Run pending migrations
yarn migration:run
# Revert last migration
yarn migration:revert
# Create empty migration file
yarn migration:create ./src/database/migrations/{migration-name}
# Build for production
yarn build:prod
# Start production server
yarn start:prod
- β JWT Authentication - Secure authentication system
- β Role-based Access Control - User permissions and roles
- β API Documentation - Auto-generated Swagger docs
- β Database Migrations - TypeORM migration system
- β Environment Configuration - Development, staging, production configs
- β Input Validation - Request validation with class-validator
- β Error Handling - Comprehensive error handling
- β Logging - Structured logging system
- β Health Checks - Application health monitoring
- β Rate Limiting - API rate limiting protection
- β CORS Support - Cross-origin resource sharing
- β Security Headers - Helmet.js security headers
- β Code Quality - ESLint, Prettier, Husky pre-commit hooks
- β Testing Setup - Unit and E2E testing with Jest
This project uses modern tooling for maintaining code quality:
- π ESLint v9 with flat config format (
eslint.config.mjs
) - πΊ Husky v9 for Git hooks
- π lint-staged for pre-commit linting
- π¬ commitlint for conventional commit messages
Git hooks are automatically set up when you run yarn
. The hooks will:
- π Run ESLint and Prettier on staged files before commit
- β Validate commit messages follow conventional commit format
This project includes comprehensive documentation:
- π οΈ Setup and Development
- ποΈ Architecture
- π Naming Cheatsheet
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- π Narek Hakobyan for the original awesome-nest-boilerplate
- π― The NestJS team for the amazing framework
- πͺ The TypeScript team for making JavaScript better
- π₯ All the open-source contributors who made this possible
β Star this repo if you found it helpful!
Made with β€οΈ by developers, for developers