import { applyDecorators, SetMetadata, UseGuards } from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; import { ApiBearerAuth, ApiUnauthorizedResponse } from '@nestjs/swagger'; import { MoreLevelGuard } from 'kkk-lib/auth/more-level.guard'; import { ManagerOnlyGuard } from 'kkk-lib/auth/manager-only.guard'; // export const MoreLevel = (...args: string[]) => SetMetadata('more-level', args); export function ManagerOnly(...roles: string[]) { return applyDecorators( SetMetadata('roles', roles), UseGuards(AuthGuard('jwt'), ManagerOnlyGuard), ApiBearerAuth(), ApiUnauthorizedResponse({ description: 'manager only' }), ); }