Getting Started
Prerequisites
Before you begin, ensure you have the following installed:
Quick Start
# Clone the repository using degit
npx degit NarHakobyan/awesome-nest-boilerplate my-nest-app
# Navigate to the project directory
cd my-nest-app
# Create environment variables file
cp .env.example .env
# Install dependencies
pnpm install
# Configure your database settings in .env file
# DB_HOST=localhost
# DB_PORT=5432
# DB_USERNAME=postgres
# DB_PASSWORD=postgres
# DB_DATABASE=nest_boilerplate
# Start the development server
pnpm start:devYour application will be available at http://localhost:3000 and API documentation at http://localhost:3000/documentation.
Available Scripts
Development
# Start development server with Vite
pnpm start:dev
# Start with NestJS CLI (alternative)
pnpm nest:start:dev
# Start with file watching
pnpm watch:dev
# Start with debugger
pnpm nest:start:debugProduction
# Build for production
pnpm build:prod
# Start production server
pnpm start:prodTesting
# Run unit tests
pnpm test
# Run tests in watch mode
pnpm test:watch
# Run e2e tests
pnpm test:e2e
# Run test coverage
pnpm test:cov
# Run tests with debugger
pnpm test:debugDatabase Operations
# Generate new migration
pnpm migration:generate -- --name=[migration-name]
# Create empty migration
pnpm migration:create src/database/migrations/[migration-name]
# Run pending migrations
pnpm migration:run
# Show migration status
pnpm migration:show
# Revert last migration
pnpm migration:revert
# Drop database schema
pnpm schema:dropCode Quality
# Run ESLint
pnpm lint
# Fix ESLint issues
pnpm lint:fix
# Update dependencies
pnpm tazeRuntime Support
This boilerplate supports multiple JavaScript runtimes for maximum flexibility:
Node.js (Default)
The traditional and most stable runtime environment with full ecosystem support.
# Development
pnpm start:dev
# Production
pnpm build:prod && pnpm start:prodBun
High-performance JavaScript runtime with built-in bundler and package manager.
# Start development server with Bun
bun start:dev:bun
# Watch mode with Bun
bun watch:bun
# Run tests with Bun
bun test
# Build with Bun
bun build:bunDeno
Secure runtime for JavaScript and TypeScript with built-in tooling.
# Start development server with Deno
deno task start
# Watch mode with Deno
deno task watch
# Run tests with Deno
deno task test
# Build with Deno
deno task buildrInitial Setup Checklist
After creating your project, complete these steps:
1. Project Configuration
- [ ] Update
package.jsonwith your project details (name, description, author) - [ ] Modify
LICENSEwith your name/organization - [ ] Update
README.mdwith project-specific information - [ ] Remove
.githubfolder if not needed
2. Environment Setup
- [ ] Configure
.envwith your environment variables:env# Database DB_HOST=localhost DB_PORT=5432 DB_USERNAME=postgres DB_PASSWORD=postgres DB_DATABASE=nest_boilerplate # JWT (RSA key pair — see .env.example for format) JWT_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----" JWT_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----" # Application PORT=3000 NODE_ENV=development # CORS CORS_ORIGINS=http://localhost:3000
3. Database Setup
- [ ] Set up your PostgreSQL database
- [ ] Update database configurations in
.env - [ ] Run initial migrations:
pnpm migration:run
4. Development Environment
- [ ] Configure your IDE/editor with TypeScript support
- [ ] Install recommended extensions (ESLint, Biome)
- [ ] Set up git hooks (Husky is pre-configured)
Environment Configuration
The application supports multiple environments:
- Development: Full debugging, hot reload, detailed logging
- Staging: Production-like environment for testing
- Production: Optimized for performance and security
Key environment variables:
| Variable | Description | Default |
|---|---|---|
NODE_ENV | Environment mode | development |
PORT | Application port | 3000 |
DB_HOST | Database host | localhost |
DB_PORT | Database port | 5432 |
JWT_PRIVATE_KEY / JWT_PUBLIC_KEY | RSA key pair for JWT signing (RS256) | Required |
CORS_ORIGINS | Allowed CORS origins | http://localhost:3000 |
Next Steps
Explore the Architecture: Read the Architecture Documentation to understand the project structure and design patterns
Development Setup: Check the Development Guide for detailed development instructions and Docker setup
Code Standards: Review the Code Style and Patterns for coding conventions and best practices
API Documentation: Visit
http://localhost:3000/documentationwhen running the server to explore the auto-generated Swagger documentationTesting: Learn about testing strategies in the Testing Guide
Deployment: When ready to deploy, consult the Deployment Guide
Naming Conventions: Reference the Naming Cheatsheet for consistent naming across your project