{"id":30160069,"url":"https://github.com/jayakrishnan-mk/nestjs-mongodb--boilerplate","last_synced_at":"2026-04-04T20:32:09.434Z","repository":{"id":307834440,"uuid":"1030841666","full_name":"Jayakrishnan-mk/NestJs-MongoDB--Boilerplate","owner":"Jayakrishnan-mk","description":"A comprehensive NestJS boilerplate with MongoDB, JWT authentication, file upload, Redis caching, and rate limiting.","archived":false,"fork":false,"pushed_at":"2025-08-02T13:14:02.000Z","size":30,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-11T15:30:52.937Z","etag":null,"topics":["file-upload","jwt","mongodb","mongoose","nestjs","redis"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jayakrishnan-mk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-02T12:48:17.000Z","updated_at":"2025-08-02T13:14:05.000Z","dependencies_parsed_at":"2025-08-02T14:36:14.297Z","dependency_job_id":"21df8d0a-04cf-403e-8432-bec77a51a692","html_url":"https://github.com/Jayakrishnan-mk/NestJs-MongoDB--Boilerplate","commit_stats":null,"previous_names":["jayakrishnan-mk/nestjs-mongodb--boilerplate"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Jayakrishnan-mk/NestJs-MongoDB--Boilerplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jayakrishnan-mk%2FNestJs-MongoDB--Boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jayakrishnan-mk%2FNestJs-MongoDB--Boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jayakrishnan-mk%2FNestJs-MongoDB--Boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jayakrishnan-mk%2FNestJs-MongoDB--Boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jayakrishnan-mk","download_url":"https://codeload.github.com/Jayakrishnan-mk/NestJs-MongoDB--Boilerplate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jayakrishnan-mk%2FNestJs-MongoDB--Boilerplate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31413267,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T20:09:54.854Z","status":"ssl_error","status_checked_at":"2026-04-04T20:09:44.350Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["file-upload","jwt","mongodb","mongoose","nestjs","redis"],"created_at":"2025-08-11T15:25:42.663Z","updated_at":"2026-04-04T20:32:09.406Z","avatar_url":"https://github.com/Jayakrishnan-mk.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NestJS Boilerplate\n\nA comprehensive NestJS boilerplate with MongoDB, JWT authentication, file upload, Redis caching, and rate limiting.\n\n## 🚀 Features\n\n- **NestJS** - Progressive Node.js framework\n- **MongoDB** - NoSQL database with Mongoose ODM\n- **JWT Authentication** - Secure token-based authentication\n- **File Upload** - Image upload with validation\n- **Redis Caching** - High-performance caching\n- **Rate Limiting** - API rate limiting protection\n- **Docker** - Containerized development and deployment\n- **Environment Configuration** - Separate dev/prod configs\n- **Validation** - Request validation with class-validator\n- **CORS** - Cross-origin resource sharing enabled\n\n## 📋 Prerequisites\n\n- Node.js (v18 or higher)\n- Docker and Docker Compose (for containerized setup)\n- MongoDB (if running locally)\n- Redis (if running locally)\n\n## 🛠️ Installation\n\n### Option 1: Local Development\n\n1. **Clone and install dependencies:**\n   ```bash\n   git clone https://github.com/Jayakrishnan-mk/NestJs-MongoDB--Boilerplate.git\n   cd project-name\n   npm install\n   ```\n\n2. **Set up environment:**\n   ```bash\n   # Copy environment files\n   cp env.dev .env.dev\n   cp env.prod .env.prod\n   \n   # Edit the environment files with your configuration\n   ```\n\n3. **Start MongoDB and Redis:**\n   ```bash\n   # Using Docker (recommended)\n   docker run -d --name mongodb -p 27017:27017 mongo:6.0\n   docker run -d --name redis -p 6379:6379 redis:7-alpine\n   \n   # Or install locally\n   ```\n\n4. **Run the application:**\n   ```bash\n   # Development\n   npm run start:dev\n   \n   # Production\n   npm run build\n   npm run start:prod\n   ```\n\n### Option 2: Docker Setup (Recommended)\n\n1. **Start all services:**\n   ```bash\n   docker-compose up -d\n   ```\n\n2. **View logs:**\n   ```bash\n   docker-compose logs -f app\n   ```\n\n3. **Stop services:**\n   ```bash\n   docker-compose down\n   ```\n\n## 🔧 Configuration\n\n### Environment Variables\n\nCreate `.env.dev` and `.env.prod` files:\n\n```env\n# Database Configuration\nMONGODB_URI=mongodb://localhost:27017/project-name-dev\n\n# JWT Configuration\nJWT_SECRET=your-super-secret-jwt-key-change-this-in-production\nJWT_EXPIRES_IN=7d\n\n# Redis Configuration\nREDIS_HOST=localhost\nREDIS_PORT=6379\nREDIS_PASSWORD=\n\n# Rate Limiting\nTHROTTLE_TTL=60\nTHROTTLE_LIMIT=100\n\n# File Upload\nMAX_FILE_SIZE=5242880\nUPLOAD_DEST=./uploads\n\n# Server Configuration\nPORT=3000\nNODE_ENV=development\n```\n\n## 📚 API Documentation\n\n### Authentication Endpoints\n\n#### Register User\n```http\nPOST /api/auth/register\nContent-Type: application/json\n\n{\n  \"email\": \"user@example.com\",\n  \"password\": \"password123\",\n  \"firstName\": \"John\",\n  \"lastName\": \"Doe\"\n}\n```\n\n#### Login User\n```http\nPOST /api/auth/login\nContent-Type: application/json\n\n{\n  \"email\": \"user@example.com\",\n  \"password\": \"password123\"\n}\n```\n\n### User Endpoints (Protected)\n\n#### Get User Profile\n```http\nGET /api/users/profile\nAuthorization: Bearer \u003cjwt-token\u003e\n```\n\n#### Get All Users\n```http\nGET /api/users\nAuthorization: Bearer \u003cjwt-token\u003e\n```\n\n#### Get User by ID\n```http\nGET /api/users/:id\nAuthorization: Bearer \u003cjwt-token\u003e\n```\n\n#### Update User\n```http\nPATCH /api/users/:id\nAuthorization: Bearer \u003cjwt-token\u003e\nContent-Type: application/json\n\n{\n  \"firstName\": \"Updated Name\"\n}\n```\n\n#### Delete User\n```http\nDELETE /api/users/:id\nAuthorization: Bearer \u003cjwt-token\u003e\n```\n\n### File Upload Endpoints (Protected)\n\n#### Upload Image\n```http\nPOST /api/upload/image\nAuthorization: Bearer \u003cjwt-token\u003e\nContent-Type: multipart/form-data\n\nfile: \u003cimage-file\u003e\n```\n\n### Health Check\n\n#### Health Status\n```http\nGET /api/health\n```\n\n## 🏗️ Project Structure\n\n```\nsrc/\n├── auth/                 # Authentication module\n│   ├── guards/          # JWT guards\n│   ├── strategies/      # Passport strategies\n│   ├── auth.controller.ts\n│   ├── auth.service.ts\n│   └── auth.module.ts\n├── users/               # Users module\n│   ├── dto/            # Data transfer objects\n│   ├── schemas/        # Mongoose schemas\n│   ├── users.controller.ts\n│   ├── users.service.ts\n│   └── users.module.ts\n├── upload/              # File upload module\n│   ├── upload.controller.ts\n│   └── upload.module.ts\n├── cache/               # Redis cache module\n│   └── cache.module.ts\n├── config/              # Configuration\n│   └── configuration.ts\n├── database/            # Database configuration\n│   └── database.module.ts\n├── app.controller.ts\n├── app.service.ts\n├── app.module.ts\n└── main.ts\n```\n\n## 🧪 Testing\n\n```bash\n# Unit tests\nnpm run test\n\n# e2e tests\nnpm run test:e2e\n\n# Test coverage\nnpm run test:cov\n```\n\n## 📦 Available Scripts\n\n- `npm run start:dev` - Start development server\n- `npm run start:prod` - Start production server\n- `npm run build` - Build the application\n- `npm run test` - Run unit tests\n- `npm run test:e2e` - Run e2e tests\n- `npm run test:cov` - Run test coverage\n\n## 🔒 Security Features\n\n- JWT token authentication\n- Password hashing with bcrypt\n- Rate limiting protection\n- Input validation and sanitization\n- CORS configuration\n- Environment variable protection\n\n## 🚀 Deployment\n\n### Docker Deployment\n\n1. **Build and run:**\n   ```bash\n   docker-compose -f docker-compose.yml up -d\n   ```\n\n2. **Production deployment:**\n   ```bash\n   # Set NODE_ENV=production in environment\n   docker-compose -f docker-compose.prod.yml up -d\n   ```\n\n### Manual Deployment\n\n1. **Build the application:**\n   ```bash\n   npm run build\n   ```\n\n2. **Set production environment:**\n   ```bash\n   export NODE_ENV=production\n   ```\n\n3. **Start the application:**\n   ```bash\n   npm run start:prod\n   ```\n\n## 🤝 Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 🆘 Support\n\nIf you encounter any issues or have questions, please:\n\n1. Check the [Issues](https://github.com/your-repo/issues) page\n2. Create a new issue with detailed information\n3. Contact the development team\n\n---\n\n**Happy Coding! 🎉**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjayakrishnan-mk%2Fnestjs-mongodb--boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjayakrishnan-mk%2Fnestjs-mongodb--boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjayakrishnan-mk%2Fnestjs-mongodb--boilerplate/lists"}