A comprehensive NestJS starter template with built-in authentication (JWT + Google OAuth), MongoDB integration, AWS S3 file uploads, and basic user management.
- NestJS Framework - Progressive Node.js framework for building server-side applications
- MongoDB Integration with Mongoose
- Authentication
- JWT Authentication
- Google OAuth 2.0
- File Storage with AWS S3
- User Management - CRUD operations
- Environment Configuration
- TypeScript - Full type safety throughout the application
- Node.js (v14 or newer)
- MongoDB (local instance or MongoDB Atlas)
- AWS Account (for S3 bucket access)
- Google Developer Console project (for OAuth)
- Clone the repository
git clone https://github.com/Datodia/nestjs-starter.git
cd nestjs-starter- Install dependencies
npm install- Set up environment variables by creating a
.envfile in the root directory:
MONGO_URI=
FRONT_URI=
PORT=
JWT_SECRET=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_BUCKET_NAME=
AWS_REGION=
CLOUD_FRONT_URI=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_CALLBACK_URL=
CORS_ORIGIN=
npm run start:devnpm run build
npm run start:prodPOST /auth/register- Register a new userPOST /auth/login- Login with email and passwordGET /auth/google- Initiate Google OAuth loginGET /auth/google/callback- Google OAuth callbackGET /auth/current-user- 🔒 Get current user profile (requires authentication)
GET /users- 🔒 Get all users (admin only)GET /users/:id- 🔒 Get user by IDPATCH /users/:id- 🔒 Update userDELETE /users/:id- 🔒 Delete user
- User registers or logs in with email/password
- Server validates credentials and returns a JWT token
- Subsequent requests include this token in the Authorization header
- User initiates authentication via
/auth/googleendpoint - After successful Google authentication, user is redirected back with a code
- Server exchanges this code for user information
- User is either logged in or a new account is created
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.