{"id":30139543,"url":"https://github.com/dfanso/nestjs-boilerplate","last_synced_at":"2026-02-08T07:32:24.312Z","repository":{"id":302929566,"uuid":"1013973271","full_name":"DFanso/nestjs-boilerplate","owner":"DFanso","description":"A production-ready NestJS boilerplate with JWT authentication, Prisma ORM, Supabase PostgreSQL, and modern development tools.","archived":false,"fork":false,"pushed_at":"2026-01-31T07:33:27.000Z","size":726,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-31T20:33:31.379Z","etag":null,"topics":["helmet","jwt","nestjs","prisma"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DFanso.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-04T19:49:19.000Z","updated_at":"2026-01-31T09:27:12.000Z","dependencies_parsed_at":"2025-07-04T20:38:11.353Z","dependency_job_id":"c60808ef-287e-4c4f-9de6-65b7b5ea7b89","html_url":"https://github.com/DFanso/nestjs-boilerplate","commit_stats":null,"previous_names":["dfanso/nestjs-boilerplate"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/DFanso/nestjs-boilerplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DFanso%2Fnestjs-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DFanso%2Fnestjs-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DFanso%2Fnestjs-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DFanso%2Fnestjs-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DFanso","download_url":"https://codeload.github.com/DFanso/nestjs-boilerplate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DFanso%2Fnestjs-boilerplate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29224439,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-08T06:05:31.539Z","status":"ssl_error","status_checked_at":"2026-02-08T05:58:33.853Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["helmet","jwt","nestjs","prisma"],"created_at":"2025-08-11T02:14:58.715Z","updated_at":"2026-02-08T07:32:24.300Z","avatar_url":"https://github.com/DFanso.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NestJS Boilerplate\n\nA production-ready NestJS boilerplate with JWT authentication, Prisma ORM, Supabase PostgreSQL, and modern development tools.\n\n## Features\n\n- **JWT Authentication** with ES256 (ECDSA) encryption\n- **Prisma ORM v7** with PostgreSQL (local or cloud-hosted)\n- **NestJS v11** with Express v5\n- **API Versioning** (v1) with Swagger documentation\n- **Security** with Helmet, CORS, and rate limiting\n- **Repository Pattern** for clean architecture\n- **Request Logging** with Morgan\n- **Context Management** with nestjs-cls\n- **TypeScript** with strict type checking\n- **Swagger/OpenAPI** documentation\n- **Testing** setup with Jest v30\n- **Modern ESLint** with TypeScript v8 support\n- **Development** tools and hot reload\n\n## Tech Stack\n\n| Technology | Purpose | Version |\n|------------|---------|---------|\n| ![NestJS](https://img.shields.io/badge/nestjs-E0234E?style=flat\u0026logo=nestjs\u0026logoColor=white) | Backend Framework | ^11.1.12 |\n| ![TypeScript](https://img.shields.io/badge/typescript-3178C6?style=flat\u0026logo=typescript\u0026logoColor=white) | Language | ^5.9.3 |\n| ![Prisma](https://img.shields.io/badge/prisma-2D3748?style=flat\u0026logo=prisma\u0026logoColor=white) | ORM | ^7.3.0 |\n| ![PostgreSQL](https://img.shields.io/badge/postgresql-4169E1?style=flat\u0026logo=postgresql\u0026logoColor=white) | Database | Latest |\n| ![JWT](https://img.shields.io/badge/JWT-000000?style=flat\u0026logo=jsonwebtokens\u0026logoColor=white) | Authentication | ES256 |\n| ![Swagger](https://img.shields.io/badge/swagger-85EA2D?style=flat\u0026logo=swagger\u0026logoColor=black) | API Documentation | ^11.2.5 |\n| ![Jest](https://img.shields.io/badge/jest-C21325?style=flat\u0026logo=jest\u0026logoColor=white) | Testing | ^30.2.0 |\n\n## Quick Start\n\n### Prerequisites\n\n- **Node.js** (v18 or higher, v22+ recommended)\n- **Bun** package manager\n- **PostgreSQL** database (local, Docker, or cloud-hosted like Supabase)\n- **OpenSSL** for key generation\n\n### Installation\n\n1. **Clone the repository**\n   ```bash\n   git clone https://github.com/DFanso/nestjs-boilerplate\n   cd nestjs-boilerplate\n   ```\n\n2. **Install dependencies**\n   ```bash\n   bun install\n   ```\n\n3. **Environment setup**\n   ```bash\n   # Create .env file\n   touch .env\n   \n   # Edit .env with your database credentials\n   nano .env\n   ```\n   \n   See [Environment Variables](#environment-variables) section below for required values.\n\n4. **Generate JWT keys**\n   ```bash\n   mkdir keys\n   # Generate ECDSA private key\n   openssl ecparam -name prime256v1 -genkey -noout -out keys/private.pem\n   # Generate public key\n   openssl ec -in keys/private.pem -pubout -out keys/public.pem\n   ```\n\n5. **Database setup**\n   \n   **Option A: Using Docker (Recommended for local development)**\n   ```bash\n   # Start PostgreSQL in Docker\n   docker-compose up postgres -d\n   \n   # Generate Prisma client\n   bunx prisma generate\n   \n   # Apply database migrations\n   bunx prisma migrate deploy\n   ```\n   \n   **Option B: Using existing PostgreSQL**\n   ```bash\n   # Ensure PostgreSQL is running and database exists\n   # Then generate Prisma client\n   bunx prisma generate\n   \n   # Push schema to database\n   bunx prisma db push\n   ```\n\n6. **Start development server**\n   ```bash\n   bun run dev\n   ```\n\n   **Your API is now running at** `http://localhost:9000`\n\n## Environment Variables\n\nCreate a `.env` file in the project root:\n\n### Local PostgreSQL Database\n```env\n# Application Configuration\nNODE_ENV=development\n\n# Database Configuration (Local PostgreSQL)\nDATABASE_URL=\"postgresql://postgres:postgres@localhost:5432/nestjs_boilerplate\"\n\n# JWT Configuration\nJWT_PRIVATE_KEY_PATH=\"./keys/private.pem\"\nJWT_PUBLIC_KEY_PATH=\"./keys/public.pem\"\n\n# Application Configuration\nALLOWED_ORIGINS=http://localhost:3000,http://localhost:3001\n```\n\n### Cloud Database (Supabase)\n```env\n# Application Configuration\nNODE_ENV=development\n\n# Database Configuration (Supabase with connection pooling)\nDATABASE_URL=\"postgresql://postgres.xxxxx:[PASSWORD]@aws-0-[region].pooler.supabase.com:6543/postgres\"\n\n# JWT Configuration\nJWT_PRIVATE_KEY_PATH=\"./keys/private.pem\"\nJWT_PUBLIC_KEY_PATH=\"./keys/public.pem\"\n\n# Application Configuration\nALLOWED_ORIGINS=http://localhost:3000,http://localhost:3001\n```\n\n\u003e **Note:** Prisma v7 uses `prisma.config.ts` for database configuration. The `DATABASE_URL` from your `.env` file is automatically loaded.\n\n## API Documentation\n\nOnce the server is running, visit:\n\n- **Swagger UI**: `http://localhost:9000/doc`\n- **API Base URL**: `http://localhost:9000/v1`\n\n### Authentication Endpoints\n\n| Method | Endpoint | Description |\n|--------|----------|-------------|\n| `POST` | `/v1/auth/register` | Register a new user |\n| `POST` | `/v1/auth/login` | Login and get JWT token |\n| `GET` | `/v1/auth/profile` | Get user profile (protected) |\n\n### Example Requests\n\n**Register User:**\n```bash\ncurl -X POST http://localhost:9000/v1/auth/register \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"email\": \"user@example.com\",\n    \"password\": \"securePassword123\"\n  }'\n```\n\n**Login:**\n```bash\ncurl -X POST http://localhost:9000/v1/auth/login \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"email\": \"user@example.com\",\n    \"password\": \"securePassword123\"\n  }'\n```\n\n**Get Profile:**\n```bash\ncurl -X GET http://localhost:9000/v1/auth/profile \\\n  -H \"Authorization: Bearer YOUR_JWT_TOKEN\"\n```\n\n## Project Structure\n\n```\n.\n├── src/\n│   ├── auth/                    # Authentication module\n│   │   ├── auth.controller.ts\n│   │   ├── auth.service.ts\n│   │   ├── auth.module.ts\n│   │   ├── jwt.strategy.ts\n│   │   ├── jwt-auth.guard.ts\n│   │   └── dto/\n│   ├── users/                   # Users module\n│   │   ├── users.service.ts\n│   │   ├── users.repository.ts\n│   │   ├── users.module.ts\n│   │   └── dto/\n│   ├── prisma/                  # Prisma service\n│   │   ├── prisma.service.ts\n│   │   └── prisma.module.ts\n│   ├── utils/                   # Utility functions\n│   │   ├── request-logging.ts\n│   │   └── exception-filter.ts\n│   ├── app.module.ts            # Root module\n│   ├── app.controller.ts        # Root controller\n│   ├── app.service.ts           # Root service\n│   └── main.ts                  # Application entry point\n├── prisma/\n│   ├── schema.prisma            # Database schema\n│   └── migrations/              # Database migrations\n├── prisma.config.ts             # Prisma v7 configuration\n├── docker-compose.yml           # Docker configuration\n└── package.json                 # Dependencies\n```\n\n## Available Scripts\n\n| Script | Description |\n|--------|-------------|\n| `bun run start` | Start production server |\n| `bun run dev` | Start development server with hot reload |\n| `bun run start:debug` | Start server in debug mode |\n| `bun run build` | Build the application |\n| `bun run test` | Run unit tests |\n| `bun run test:e2e` | Run end-to-end tests |\n| `bun run test:cov` | Run tests with coverage |\n\n## Database Operations\n\n### Prisma Commands\n\n| Command | Description |\n|---------|-------------|\n| `bunx prisma generate` | Generate Prisma client |\n| `bunx prisma db push` | Push schema to database (dev) |\n| `bunx prisma migrate dev` | Create and apply migration (dev) |\n| `bunx prisma migrate deploy` | Apply migrations (production) |\n| `bunx prisma studio` | Open Prisma Studio GUI |\n| `bunx prisma migrate status` | Check migration status |\n| `bunx prisma validate` | Validate schema and config |\n\n\u003e **Note:** Prisma v7 uses `prisma.config.ts` for configuration. Database URL and migration paths are defined there.\n\n### Database Schema\n\n```prisma\nmodel User {\n  id        String     @id @default(cuid())\n  email     String     @unique\n  password  String\n  createdAt DateTime   @default(now())\n  updatedAt DateTime   @updatedAt\n  roles     UserRole[]\n}\n\nmodel UserRole {\n  id     String @id @default(cuid())\n  user   User   @relation(fields: [userId], references: [id])\n  userId String\n  role   Role\n}\n\nenum Role {\n  USER\n  ADMIN\n}\n```\n\n## Security Features\n\n- **Helmet** - Security headers\n- **CORS** - Cross-origin resource sharing\n- **Rate Limiting** - Request throttling\n- **JWT with ES256** - Asymmetric encryption\n- **Password Hashing** - bcrypt with salt rounds\n- **Input Validation** - class-validator pipes\n- **SQL Injection Protection** - Prisma ORM\n\n## Testing\n\n```bash\n# Run unit tests\nbun run test\n\n# Run tests in watch mode\nbun run test:watch\n\n# Run e2e tests\nbun run test:e2e\n\n# Generate coverage report\nbun run test:cov\n```\n\n## Recent Updates\n\n### January 2026 Update\n- ⬆️ Updated **NestJS** packages from v11.1.9 to v11.1.12\n- ⬆️ Updated **Prisma ORM** from v7.1.0 to v7.3.0\n- ⬆️ Updated **@nestjs/swagger** from v11.2.3 to v11.2.5\n- ⬆️ Updated **@nestjs/cli** from v11.0.14 to v11.0.16\n- ⬆️ Updated **TypeScript ESLint** from v8.49.0 to v8.54.0\n- ⬆️ Updated **nestjs-cls** from v6.1.0 to v6.2.0\n- ⬆️ Updated **Prettier** from v3.7.4 to v3.8.1\n- ⬆️ Updated **@types/node** from v24.10.2 to v25.1.0\n- ⬆️ Updated **supertest** from v7.1.4 to v7.2.2\n\n### Version 11 (December 2025)\n- ✨ Upgraded to **NestJS v11** with Express v5\n- ✨ Upgraded to **Prisma ORM v7** with new config system\n- ✨ Upgraded to **Jest v30** for improved performance\n- ✨ Upgraded to **TypeScript ESLint v8**\n- ✨ Updated all dependencies to latest stable versions\n- 🔧 Migrated database configuration to `prisma.config.ts`\n- 🔧 Made `ALLOWED_ORIGINS` optional with sensible defaults\n- 🔧 Simplified local database setup (removed DIRECT_URL requirement)\n\n## Documentation\n\n- [Database Migration Guide](./docs/DATABASE_MIGRATION_GUIDE.md)\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 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## Acknowledgments\n\n- [NestJS](https://nestjs.com/) - Progressive Node.js framework\n- [Prisma](https://prisma.io/) - Next-generation ORM\n- [PostgreSQL](https://postgresql.org/) - Advanced open source database\n- [Swagger](https://swagger.io/) - API documentation\n- [Jest](https://jestjs.io/) - Delightful testing framework\n\n## Support\n\nIf you have any questions or need help, please:\n\n- Open an issue on GitHub\n- Check the documentation\n- Search existing issues\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdfanso%2Fnestjs-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdfanso%2Fnestjs-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdfanso%2Fnestjs-boilerplate/lists"}