About Guards
Authentication and authorization guards
Browse the snippets below to find the guards implementation you need for your NestJS project.
All Guards Snippets
JWT Auth Guard
JWT authentication with Passport
- Passport integration
- Public route support
- Token expiration handling
API Key Guard
API key authentication for services
- Timing-safe comparison
- Multiple extraction methods
- Multiple API keys support
Roles Guard
Role-based access control
- OR logic (any role)
- AND logic (all roles)
- Custom error messages
Throttle Guard
Rate limiting guard
- Customizable limits
- @Throttle decorator
- @SkipThrottle decorator
How to Use
Install any snippet using the Hanma CLI:
npx hanma add --framework nest
For example, to install the first snippet:
npx hanma add jwt-auth-guard --framework nest