A comprehensive, production-ready NestJS monolithic template with authentication, database integration, caching, and more. Perfect for developers who want to jump-start their backend development with a well-structured, scalable foundation.
- JWT-based authentication with Passport.js
- Role-based access control (RBAC) with custom decorators
- Basic authentication support
- Guards for route protection
- Password hashing with bcrypt
- TypeORM for PostgreSQL with auto-loading entities
- Mongoose for MongoDB integration
- Database migrations and synchronization
- Entity relationships and validation
- Redis integration for caching and session management
- Rate limiting with ThrottlerGuard
- Request/Response logging with custom interceptors
- Global exception filtering
- Swagger/OpenAPI documentation
- Auto-generated API docs at
/api/docs - Bearer token authentication support
- Request/Response schemas
- Environment-based configuration (local, dev, qa, prod)
- ESLint and Prettier for code formatting
- Jest testing framework with coverage
- E2E testing setup
- Hot reload in development mode
- Static file serving for uploads
- Image processing capabilities with Sharp
- Multer for file uploads
- Node.js (v18 or higher)
- PostgreSQL
- MongoDB (optional)
- Redis (optional)
-
Clone the repository
git clone https://github.com/ervikassingh/nestjs-monolithic-template.git cd nestjs-monolithic-template -
Install dependencies
npm install
-
Environment Setup Create environment files based on your deployment stage:
# Copy the example environment file cp .env.example .env.local
# Start with hot reload
npm run start:local:watch
# Start with debug mode
npm run start:local:debug# Build for production
npm run build:prod
# Start production server
npm run start:prodnpm run start:local # Start local environment
npm run start:local:watch # Start with file watching
npm run start:local:debug # Start with debug mode
npm run start:dev # Start development environment
npm run start:qa # Start QA environmentnpm run build:local # Build for local environment
npm run build:dev # Build for development
npm run build:qa # Build for QA
npm run build:prod # Build for productionnpm run test # Run unit tests
npm run test:watch # Run tests in watch mode
npm run test:cov # Run tests with coverage
npm run test:e2e # Run end-to-end tests
npm run test:e2e:watch # Run e2e tests in watch modenpm run lint # Run ESLint
npm run format # Format code with PrettierThe application supports multiple environment configurations:
local- Local developmentdev- Development environmentqa- Quality assuranceprod- Production environment
- PostgreSQL: Primary database with TypeORM
- MongoDB: Optional NoSQL database with Mongoose
- Redis: Caching and session storage
- Rate Limiting: Configurable throttling per endpoint
- CORS: Cross-origin resource sharing enabled
- Validation: Request validation with class-validator
- Exception Handling: Global exception filter
Once the application is running, visit:
- Swagger UI:
http://localhost:3000/api/docs - API Base URL:
http://localhost:3000/api
# Build the Docker image
docker build -t nestjs-monolithic-template .
# Run the container
docker run -p 3000:3000 nestjs-monolithic-template- Build the application:
npm run build:prod - Set environment variables
- Start the application:
npm run start:prod
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Documentation: NestJS Docs
- Community: NestJS Discord
- Issues: GitHub Issues
- Author: ervikassingh
- NestJS - The Node.js framework
- TypeORM - ORM for TypeScript and JavaScript
- Mongoose - MongoDB object modeling
- Redis - In-memory data structure store
Happy Coding! π