Are you tired of rebuilding the same authentication flow every time you start a NestJS project?
I’ve created a robust NestJS starter template that includes everything you need to launch a secure, scalable application – with OAuth2 (Google & GitHub), JWT session management, Redis cache, PostgreSQL, environment validation, and full testing setup.
Ideal for production-ready apps, prototypes, and team onboarding.
👉 GitHub Repo: https://github.com/JimmyCamus/nest-oauth2-template
✅ Features
- 🧱 Modular NestJS 11+ structure
- 🔐 OAuth2 via Google & GitHub
- 🔑 JWT-based auth
- 🚀 Redis for caching and session management
- 🐘 PostgreSQL with TypeORM
- 📦 Centralized & validated config
- 📊 Logging with nestjs-pino
- 🧪 Full unit & e2e tests
- 📡 Health check endpoint
🧪 Ready-to-use Endpoints
- GET /auth/google → Redirects to Google login
- GET /auth/google/redirect → Handles Google callback
- GET /auth/github → Redirects to GitHub login
- GET /auth/github/redirect → Handles GitHub callback
- GET /auth/profile → Returns the logged-in user's profile (requires JWT)
- GET /health → Health check with app uptime and status
🔧 Configuration
All environment variables are validated at startup.
- Includes config for:
- Google & GitHub OAuth
- JWT secrets
- PostgreSQL connection
- Redis host/password
Just copy .env.example and replace with your own values.
🔍 Why Use This Template?
This is more than a simple starter — it's designed for real-world applications, with:
- OAuth2 auth fully configured with Passport strategies
- Token-based sessions via JWT
- Redis cache integration
- Validated and centralized environment configs
- Structured logs using nestjs-pino
- End-to-end and unit testing support
- Clean, extensible modular architecture
Perfect for projects where you want to skip the boilerplate and focus on building.
If you find it useful, give it a ⭐ and feel free to open an issue or PR with feedback or improvements!
Top comments (0)