Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Vatsalya-singhi/6b41affbe954880efa7a43229bfaca53 to your computer and use it in GitHub Desktop.
Save Vatsalya-singhi/6b41affbe954880efa7a43229bfaca53 to your computer and use it in GitHub Desktop.
// guard implementation in Controller
import { Controller, Get, UseGuards } from '@nestjs/common';
import { RoleGuard } from './role.guard';
@Controller('admin')
export class AdminController {
@Get()
@UseGuards(new RoleGuard('admin')) // Apply the guard for 'admin' role
findAll() {
return { message: 'Admin dashboard' };
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment