This is a starter NestJS API template with built-in authentication and user management. It provides a scalable, well-structured foundation for developing secure RESTful APIs.
- User Authentication (JWT-based login, signup, and email verification)
- JWT Refresh Token Mechanism (Automatic access token renewal)
- Secure Password Hashing (Using bcrypt)
- Email Verification & Password Reset (Using MailerModule)
- API Documentation (Swagger UI)
- Error Handling & Logging (Global exception filters and logging)
- Modular Structure (Easily extendable and maintainable)
- API Versioning (Supports multiple versions)
You can quickly scaffold a new project using npx:
npx nestjs-api-starter my-app
cd my-app
npm install
npm run start:devThis will create a new NestJS API project in the my-app directory.
Alternatively, you can clone the repository manually:
git clone https://github.com/your-repo/nestjs-api-starter.git
cd nestjs-api-starter
npm installCreate a .env file in the root directory same as .env.example
npm run start:devAPI is now running on: http://localhost:3000
| Method | Endpoint | Description |
|---|---|---|
POST |
/auth/signup |
Register a new user |
POST |
/auth/login |
User login, returns JWT token |
GET |
/auth/verify?token=... |
Verify email address |
POST |
/auth/forgot-password |
Send password reset email |
POST |
/auth/reset-password |
Reset password using token |
POST |
/auth/refresh-token |
Get a new access token |
| Method | Endpoint | Description |
|---|---|---|
GET |
/users/profile |
Get authenticated user profile |
Swagger documentation is available at:
http://localhost:3000/api/docs
- Use environment variables for sensitive data.
- Store refresh tokens securely (preferably in HTTP-only cookies).
- Use HTTPS in production.
- Rotate refresh tokens to prevent misuse.
- Enable rate limiting & security middleware.
- NestJS - Modular TypeScript framework for Node.js
- Mongoose - MongoDB Object Modeling
- JWT - JSON Web Token for authentication
- Bcrypt - Secure password hashing
- Swagger - API Documentation
- MailerModule - Email support for verification & password resets
Feel free to submit issues or pull requests to improve this starter template.
This project is open-source and available under the MIT License.
Happy coding!
