Overview
This page collects 10 code snippets related to authorization for NestJS. Browse below to find the perfect solution for your needs.
Snippets by Category
Decorators
Current User
Extract authenticated user from request
npx hanma add current-user --framework nest
Roles Decorator
Role-based access control decorator
npx hanma add roles --framework nest
Public Route
Mark routes as public to skip auth
npx hanma add public --framework nest
Auth Decorator
Combined authentication decorator
npx hanma add auth --framework nest
Guards
JWT Auth Guard
JWT authentication with Passport
npx hanma add jwt-auth-guard --framework nest
API Key Guard
API key authentication for services
npx hanma add api-key-guard --framework nest
Roles Guard
Role-based access control
npx hanma add roles-guard --framework nest
Throttle Guard
Rate limiting guard
npx hanma add throttle-guard --framework nest
Frequently Asked Questions
How do I implement authorization in NestJS?
Browse the snippets above and select the one that best fits your needs. Each snippet includes installation instructions and usage examples.
Are these snippets production-ready?
Yes, all snippets are designed for production use. Review and adapt to your specific requirements before deployment.
Can I use these with NestJS?
Yes, these snippets are specifically designed and tested for NestJS.