import { SetMetadata } from '@nestjs/common';
import { UserRole } from '@prisma/client';

export const REQUIRE_ROLE_KEY = 'require-role';

/**
 * Decorator to specify which roles are allowed to access a route.
 * 
 * Usage:
 * @RequireRole(UserRole.ESTATE_ADMIN, UserRole.RESIDENT)
 * @Post()
 * create(@Body() dto: CreateDto) { ... }
 * 
 * Apply RolesGuard globally or on routes to enforce this.
 */
export const RequireRole = (...roles: UserRole[]) =>
  SetMetadata(REQUIRE_ROLE_KEY, roles);
